// $ANTLR 3.1.1 ANMLTree.g 2010-06-01 17:08:43

package gov.nasa.anml.parsing;
import gov.nasa.anml.lifted.*;
import gov.nasa.anml.utility.*;


import org.antlr.runtime.*;
import org.antlr.runtime.tree.*;import java.util.Stack;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
public class ANMLTree extends TreeParser {
    public static final String[] tokenNames = new String[] {
        "<invalid>", "<EOR>", "<DOWN>", "<UP>", "Types", "Constants", "Fluents", "Actions", "Parameters", "Arguments", "Stmts", "Block", "Decompositions", "TypeRef", "LabelRef", "Ref", "Bind", "Access", "TypeRefine", "Type", "Fluent", "FluentFunction", "Constant", "ConstantFunction", "Parameter", "Action", "Label", "DefiniteInterval", "DefinitePoint", "IndefiniteInterval", "IndefinitePoint", "Bra", "Ket", "Before", "At", "After", "TBra", "TKet", "TStart", "TEnd", "TDuration", "Chain", "TimedStmt", "TimedExpr", "ContainsSomeStmt", "ContainsAllStmt", "ContainsSomeExpr", "ContainsAllExpr", "ForAllExpr", "ForAllStmt", "ExistsExpr", "ExistsStmt", "When", "WhenElse", "Enum", "Range", "ID", "This", "Boolean", "Integer", "Float", "Symbol", "String", "Object", "Vector", "Predicate", "LessThan", "Assign", "With", "Semi", "Comma", "Undefined", "Undefine", "LeftP", "RightP", "Variable", "Function", "Fact", "LeftC", "RightC", "NotLog", "NotBit", "EqualLog", "Equal", "Goal", "LeftB", "Duration", "RightB", "Decomposition", "Contains", "Else", "ForAll", "Exists", "Change", "Produce", "Consume", "Lend", "Use", "Within", "SetAssign", "Skip", "Delta", "All", "Dots", "Colon", "Implies", "XorLog", "OrLog", "AndLog", "XorBit", "Plus", "Minus", "OrBit", "Times", "Divide", "AndBit", "Unordered", "Ordered", "Dot", "Start", "End", "INT", "FLOAT", "STRING", "True", "False", "Infinity", "NotEqual", "GreaterThan", "LessThanE", "GreaterThanE", "DIGIT", "ESC", "LETTER", "WS", "SLC", "MLC", "ForallExpr"
    };
    public static final int IndefinitePoint=30;
    public static final int LessThan=66;
    public static final int Ket=32;
    public static final int Implies=105;
    public static final int OrBit=112;
    public static final int AndLog=108;
    public static final int TDuration=40;
    public static final int Stmts=10;
    public static final int LETTER=133;
    public static final int Before=33;
    public static final int Fluents=6;
    public static final int Constants=5;
    public static final int Bind=16;
    public static final int After=35;
    public static final int DefinitePoint=28;
    public static final int XorLog=106;
    public static final int LabelRef=14;
    public static final int Lend=96;
    public static final int Actions=7;
    public static final int EOF=-1;
    public static final int LessThanE=129;
    public static final int AndBit=115;
    public static final int Variable=75;
    public static final int NotLog=80;
    public static final int ForAll=91;
    public static final int When=52;
    public static final int TEnd=39;
    public static final int NotBit=81;
    public static final int Access=17;
    public static final int Undefined=71;
    public static final int Use=97;
    public static final int ContainsAllExpr=47;
    public static final int ExistsExpr=50;
    public static final int Decompositions=12;
    public static final int ForAllStmt=49;
    public static final int This=57;
    public static final int ContainsSomeExpr=46;
    public static final int TimedStmt=42;
    public static final int DefiniteInterval=27;
    public static final int Colon=104;
    public static final int INT=121;
    public static final int Action=25;
    public static final int NotEqual=127;
    public static final int TimedExpr=43;
    public static final int Equal=83;
    public static final int Fluent=20;
    public static final int With=68;
    public static final int Block=11;
    public static final int Object=63;
    public static final int Float=60;
    public static final int LeftC=78;
    public static final int Range=55;
    public static final int Minus=111;
    public static final int WS=134;
    public static final int Semi=69;
    public static final int LeftB=85;
    public static final int Function=76;
    public static final int Times=113;
    public static final int OrLog=107;
    public static final int MLC=136;
    public static final int TypeRefine=18;
    public static final int ExistsStmt=51;
    public static final int TBra=36;
    public static final int IndefiniteInterval=29;
    public static final int Else=90;
    public static final int Label=26;
    public static final int ForAllExpr=48;
    public static final int Types=4;
    public static final int End=120;
    public static final int Parameters=8;
    public static final int Fact=77;
    public static final int Unordered=116;
    public static final int Undefine=72;
    public static final int Within=98;
    public static final int LeftP=73;
    public static final int ForallExpr=137;
    public static final int ESC=132;
    public static final int All=102;
    public static final int TStart=38;
    public static final int SLC=135;
    public static final int Decomposition=88;
    public static final int False=125;
    public static final int GreaterThanE=130;
    public static final int Constant=22;
    public static final int FLOAT=122;
    public static final int Enum=54;
    public static final int ID=56;
    public static final int GreaterThan=128;
    public static final int Consume=95;
    public static final int Arguments=9;
    public static final int Assign=67;
    public static final int Change=93;
    public static final int Chain=41;
    public static final int TypeRef=13;
    public static final int Produce=94;
    public static final int WhenElse=53;
    public static final int Ordered=117;
    public static final int ConstantFunction=23;
    public static final int Bra=31;
    public static final int Exists=92;
    public static final int String=62;
    public static final int Symbol=61;
    public static final int DIGIT=131;
    public static final int Predicate=65;
    public static final int ContainsSomeStmt=44;
    public static final int True=124;
    public static final int Vector=64;
    public static final int RightP=74;
    public static final int Start=119;
    public static final int Type=19;
    public static final int At=34;
    public static final int Delta=101;
    public static final int XorBit=109;
    public static final int Contains=89;
    public static final int TKet=37;
    public static final int ContainsAllStmt=45;
    public static final int RightC=79;
    public static final int RightB=87;
    public static final int SetAssign=99;
    public static final int Duration=86;
    public static final int Divide=114;
    public static final int Parameter=24;
    public static final int Goal=84;
    public static final int Ref=15;
    public static final int Skip=100;
    public static final int Plus=110;
    public static final int Boolean=58;
    public static final int Dot=118;
    public static final int EqualLog=82;
    public static final int Dots=103;
    public static final int Infinity=126;
    public static final int Comma=70;
    public static final int Integer=59;
    public static final int STRING=123;
    public static final int FluentFunction=21;

    // delegates
    // delegators

    protected static class A_scope {
        Unit d;
        // The difference between Scope and Unit is small: Units have names.;
    }
    protected Stack A_stack = new Stack();
    protected static class S_scope {
        Scope d;
        // capital Scope is ANML-defined --- lowercase is ANTLR-defined.;
    }
    protected Stack S_stack = new Stack();
    protected static class O_scope {
        ObjectType d;
        // are we within the definition of an object (type)?  This may include field references in expressions.;
    }
    protected Stack O_stack = new Stack();
    protected static class I_scope {
        Interval i;
    }
    protected Stack I_stack = new Stack();


        public ANMLTree(TreeNodeStream input) {
            this(input, new RecognizerSharedState());
        }
        public ANMLTree(TreeNodeStream input, RecognizerSharedState state) {
            super(input, state);
             
        }
        

    public String[] getTokenNames() { return ANMLTree.tokenNames; }
    public String getGrammarFileName() { return "ANMLTree.g"; }


    /*	// ^(Boolean)
    	public static CommonTree booleanTree = new CommonTree(new CommonTree(new CommonToken(Boolean,"Boolean")));
    	// ^(Delta) // intended to be ^(Delta fluent_ref) by .setChild(0,fluent_ref.tree)
    	public static CommonTree deltaTree = new CommonTree(new CommonToken(Delta,"^"));
    	public int LA(int i) {
    		return input.LA(i);
    	}
    	public boolean LA(int i,int t) {
    		return input.LA(i)==t;
    	}
    */
    	public static int size(CommonTree t) {
    		if (t.isNil()) {
    			return t.getChildCount();
    		}
    		return 1;
    	}
    	
    	public String text(ANMLToken t) {
    		if (t.startIndex <0 || t.stopIndex <0)
    			return "null";
    		return input.getTokenStream().toString(t.startIndex,t.stopIndex);
    			
    	}
    	
    	Domain domain ;//= new Domain();



    // $ANTLR start "model"
    // ANMLTree.g:81:1: model[Domain d] : ^( Block types constants fluents actions stmts ) ;
    public final void model(Domain d) throws RecognitionException {
        I_stack.push(new I_scope());
        A_stack.push(new A_scope());
        S_stack.push(new S_scope());

         domain=d; ((S_scope)S_stack.peek()).d = d; ((A_scope)A_stack.peek()).d = d; ((I_scope)I_stack.peek()).i =d;
        try {
            // ANMLTree.g:84:2: ( ^( Block types constants fluents actions stmts ) )
            // ANMLTree.g:84:4: ^( Block types constants fluents actions stmts )
            {
            match(input,Block,FOLLOW_Block_in_model138); if (state.failed) return ;

            match(input, Token.DOWN, null); if (state.failed) return ;
            pushFollow(FOLLOW_types_in_model143);
            types();

            state._fsp--;
            if (state.failed) return ;
            pushFollow(FOLLOW_constants_in_model148);
            constants();

            state._fsp--;
            if (state.failed) return ;
            pushFollow(FOLLOW_fluents_in_model153);
            fluents();

            state._fsp--;
            if (state.failed) return ;
            pushFollow(FOLLOW_actions_in_model158);
            actions();

            state._fsp--;
            if (state.failed) return ;
            pushFollow(FOLLOW_stmts_in_model163);
            stmts();

            state._fsp--;
            if (state.failed) return ;

            match(input, Token.UP, null); if (state.failed) return ;

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
            I_stack.pop();
            A_stack.pop();
            S_stack.pop();

        }
        return ;
    }
    // $ANTLR end "model"


    // $ANTLR start "term_arg_decl_list"
    // ANMLTree.g:95:1: term_arg_decl_list[Term t] : ( ^( Parameter id type_ref ) )* ;
    public final void term_arg_decl_list(Term t) throws RecognitionException {
        SimpleString id1 = null;

        Type type_ref2 = null;


        try {
            // ANMLTree.g:96:2: ( ( ^( Parameter id type_ref ) )* )
            // ANMLTree.g:96:4: ( ^( Parameter id type_ref ) )*
            {
            // ANMLTree.g:96:4: ( ^( Parameter id type_ref ) )*
            loop1:
            do {
                int alt1=2;
                int LA1_0 = input.LA(1);

                if ( (LA1_0==Parameter) ) {
                    alt1=1;
                }


                switch (alt1) {
            	case 1 :
            	    // ANMLTree.g:96:5: ^( Parameter id type_ref )
            	    {
            	    match(input,Parameter,FOLLOW_Parameter_in_term_arg_decl_list181); if (state.failed) return ;

            	    match(input, Token.DOWN, null); if (state.failed) return ;
            	    pushFollow(FOLLOW_id_in_term_arg_decl_list183);
            	    id1=id();

            	    state._fsp--;
            	    if (state.failed) return ;
            	    pushFollow(FOLLOW_type_ref_in_term_arg_decl_list185);
            	    type_ref2=type_ref();

            	    state._fsp--;
            	    if (state.failed) return ;
            	    if ( state.backtracking==0 ) {
            	      t.parameters.put(new Parameter(id1,type_ref2));
            	    }

            	    match(input, Token.UP, null); if (state.failed) return ;

            	    }
            	    break;

            	default :
            	    break loop1;
                }
            } while (true);


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "term_arg_decl_list"


    // $ANTLR start "scope_arg_decl_list"
    // ANMLTree.g:101:1: scope_arg_decl_list[Scope d] : ( ^( Parameter id type_ref ) )* ;
    public final void scope_arg_decl_list(Scope d) throws RecognitionException {
        SimpleString id3 = null;

        Type type_ref4 = null;


        try {
            // ANMLTree.g:102:2: ( ( ^( Parameter id type_ref ) )* )
            // ANMLTree.g:102:4: ( ^( Parameter id type_ref ) )*
            {
            // ANMLTree.g:102:4: ( ^( Parameter id type_ref ) )*
            loop2:
            do {
                int alt2=2;
                int LA2_0 = input.LA(1);

                if ( (LA2_0==Parameter) ) {
                    alt2=1;
                }


                switch (alt2) {
            	case 1 :
            	    // ANMLTree.g:102:5: ^( Parameter id type_ref )
            	    {
            	    match(input,Parameter,FOLLOW_Parameter_in_scope_arg_decl_list211); if (state.failed) return ;

            	    match(input, Token.DOWN, null); if (state.failed) return ;
            	    pushFollow(FOLLOW_id_in_scope_arg_decl_list213);
            	    id3=id();

            	    state._fsp--;
            	    if (state.failed) return ;
            	    pushFollow(FOLLOW_type_ref_in_scope_arg_decl_list215);
            	    type_ref4=type_ref();

            	    state._fsp--;
            	    if (state.failed) return ;
            	    if ( state.backtracking==0 ) {
            	      d.addParameter(new Parameter(id3,type_ref4));
            	    }

            	    match(input, Token.UP, null); if (state.failed) return ;

            	    }
            	    break;

            	default :
            	    break loop2;
                }
            } while (true);


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "scope_arg_decl_list"


    // $ANTLR start "builtinType"
    // ANMLTree.g:108:1: builtinType returns [TypeCode typeCode] : (t= Boolean | t= Integer | t= Float | t= Symbol | t= String | t= Object ) ;
    public final TypeCode builtinType() throws RecognitionException {
        TypeCode typeCode = null;

        ANMLToken t=null;

        try {
            // ANMLTree.g:110:2: ( (t= Boolean | t= Integer | t= Float | t= Symbol | t= String | t= Object ) )
            // ANMLTree.g:111:2: (t= Boolean | t= Integer | t= Float | t= Symbol | t= String | t= Object )
            {
            // ANMLTree.g:111:2: (t= Boolean | t= Integer | t= Float | t= Symbol | t= String | t= Object )
            int alt3=6;
            switch ( input.LA(1) ) {
            case Boolean:
                {
                alt3=1;
                }
                break;
            case Integer:
                {
                alt3=2;
                }
                break;
            case Float:
                {
                alt3=3;
                }
                break;
            case Symbol:
                {
                alt3=4;
                }
                break;
            case String:
                {
                alt3=5;
                }
                break;
            case Object:
                {
                alt3=6;
                }
                break;
            default:
                if (state.backtracking>0) {state.failed=true; return typeCode;}
                NoViableAltException nvae =
                    new NoViableAltException("", 3, 0, input);

                throw nvae;
            }

            switch (alt3) {
                case 1 :
                    // ANMLTree.g:111:4: t= Boolean
                    {
                    t=(ANMLToken)match(input,Boolean,FOLLOW_Boolean_in_builtinType250); if (state.failed) return typeCode;
                    if ( state.backtracking==0 ) {
                      typeCode =TypeCode.Boolean;
                    }

                    }
                    break;
                case 2 :
                    // ANMLTree.g:112:4: t= Integer
                    {
                    t=(ANMLToken)match(input,Integer,FOLLOW_Integer_in_builtinType259); if (state.failed) return typeCode;
                    if ( state.backtracking==0 ) {
                      typeCode =TypeCode.Integer;
                    }

                    }
                    break;
                case 3 :
                    // ANMLTree.g:113:4: t= Float
                    {
                    t=(ANMLToken)match(input,Float,FOLLOW_Float_in_builtinType268); if (state.failed) return typeCode;
                    if ( state.backtracking==0 ) {
                      typeCode =TypeCode.Float;
                    }

                    }
                    break;
                case 4 :
                    // ANMLTree.g:114:4: t= Symbol
                    {
                    t=(ANMLToken)match(input,Symbol,FOLLOW_Symbol_in_builtinType277); if (state.failed) return typeCode;
                    if ( state.backtracking==0 ) {
                      typeCode =TypeCode.Symbol;
                    }

                    }
                    break;
                case 5 :
                    // ANMLTree.g:115:4: t= String
                    {
                    t=(ANMLToken)match(input,String,FOLLOW_String_in_builtinType286); if (state.failed) return typeCode;
                    if ( state.backtracking==0 ) {
                      typeCode =TypeCode.String;
                    }

                    }
                    break;
                case 6 :
                    // ANMLTree.g:116:4: t= Object
                    {
                    t=(ANMLToken)match(input,Object,FOLLOW_Object_in_builtinType295); if (state.failed) return typeCode;
                    if ( state.backtracking==0 ) {
                      typeCode =TypeCode.Object;
                    }

                    }
                    break;

            }

            if ( state.backtracking==0 ) {

              		//System.out.println("Builtin: " + text(t));
              	
            }

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return typeCode;
    }
    // $ANTLR end "builtinType"


    // $ANTLR start "id"
    // ANMLTree.g:122:1: id returns [SimpleString text] : ( ID | This );
    public final SimpleString id() throws RecognitionException {
        SimpleString text = null;

        ANMLToken ID5=null;

        try {
            // ANMLTree.g:123:5: ( ID | This )
            int alt4=2;
            int LA4_0 = input.LA(1);

            if ( (LA4_0==ID) ) {
                alt4=1;
            }
            else if ( (LA4_0==This) ) {
                alt4=2;
            }
            else {
                if (state.backtracking>0) {state.failed=true; return text;}
                NoViableAltException nvae =
                    new NoViableAltException("", 4, 0, input);

                throw nvae;
            }
            switch (alt4) {
                case 1 :
                    // ANMLTree.g:123:7: ID
                    {
                    ID5=(ANMLToken)match(input,ID,FOLLOW_ID_in_id319); if (state.failed) return text;
                    if ( state.backtracking==0 ) {
                      text =ID5.getSimpleText();
                    }

                    }
                    break;
                case 2 :
                    // ANMLTree.g:124:7: This
                    {
                    match(input,This,FOLLOW_This_in_id329); if (state.failed) return text;
                    if ( state.backtracking==0 ) {
                      text =((A_scope)A_stack.peek()).d.name();
                    }

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return text;
    }
    // $ANTLR end "id"


    // $ANTLR start "type_spec"
    // ANMLTree.g:127:1: type_spec returns [Type d] : ( ^( Vector ( ^( Parameters term_arg_decl_list[(VectorType)$d] ) | Parameters ) ) | ^( TypeRef builtinType ( set )? ) | ^( TypeRef id ( set )? ) | enumeration );
    public final Type type_spec() throws RecognitionException {
        Type d = null;

        TypeCode builtinType6 = null;

        Constraint set7 = null;

        SimpleString id8 = null;

        Constraint set9 = null;

        ANMLTree.enumeration_return enumeration10 = null;


         Constraint c = null; 
        try {
            // ANMLTree.g:129:5: ( ^( Vector ( ^( Parameters term_arg_decl_list[(VectorType)$d] ) | Parameters ) ) | ^( TypeRef builtinType ( set )? ) | ^( TypeRef id ( set )? ) | enumeration )
            int alt8=4;
            switch ( input.LA(1) ) {
            case Vector:
                {
                alt8=1;
                }
                break;
            case TypeRef:
                {
                int LA8_2 = input.LA(2);

                if ( (LA8_2==DOWN) ) {
                    int LA8_4 = input.LA(3);

                    if ( ((LA8_4>=Boolean && LA8_4<=Object)) ) {
                        alt8=2;
                    }
                    else if ( ((LA8_4>=ID && LA8_4<=This)) ) {
                        alt8=3;
                    }
                    else {
                        if (state.backtracking>0) {state.failed=true; return d;}
                        NoViableAltException nvae =
                            new NoViableAltException("", 8, 4, input);

                        throw nvae;
                    }
                }
                else {
                    if (state.backtracking>0) {state.failed=true; return d;}
                    NoViableAltException nvae =
                        new NoViableAltException("", 8, 2, input);

                    throw nvae;
                }
                }
                break;
            case Enum:
                {
                alt8=4;
                }
                break;
            default:
                if (state.backtracking>0) {state.failed=true; return d;}
                NoViableAltException nvae =
                    new NoViableAltException("", 8, 0, input);

                throw nvae;
            }

            switch (alt8) {
                case 1 :
                    // ANMLTree.g:129:7: ^( Vector ( ^( Parameters term_arg_decl_list[(VectorType)$d] ) | Parameters ) )
                    {
                    match(input,Vector,FOLLOW_Vector_in_type_spec355); if (state.failed) return d;

                    if ( state.backtracking==0 ) {
                      d =new VectorType();
                    }

                    match(input, Token.DOWN, null); if (state.failed) return d;
                    // ANMLTree.g:130:6: ( ^( Parameters term_arg_decl_list[(VectorType)$d] ) | Parameters )
                    int alt5=2;
                    int LA5_0 = input.LA(1);

                    if ( (LA5_0==Parameters) ) {
                        int LA5_1 = input.LA(2);

                        if ( (LA5_1==DOWN) ) {
                            alt5=1;
                        }
                        else if ( (LA5_1==UP) ) {
                            alt5=2;
                        }
                        else {
                            if (state.backtracking>0) {state.failed=true; return d;}
                            NoViableAltException nvae =
                                new NoViableAltException("", 5, 1, input);

                            throw nvae;
                        }
                    }
                    else {
                        if (state.backtracking>0) {state.failed=true; return d;}
                        NoViableAltException nvae =
                            new NoViableAltException("", 5, 0, input);

                        throw nvae;
                    }
                    switch (alt5) {
                        case 1 :
                            // ANMLTree.g:130:7: ^( Parameters term_arg_decl_list[(VectorType)$d] )
                            {
                            match(input,Parameters,FOLLOW_Parameters_in_type_spec367); if (state.failed) return d;

                            if ( input.LA(1)==Token.DOWN ) {
                                match(input, Token.DOWN, null); if (state.failed) return d;
                                pushFollow(FOLLOW_term_arg_decl_list_in_type_spec369);
                                term_arg_decl_list((VectorType)d);

                                state._fsp--;
                                if (state.failed) return d;

                                match(input, Token.UP, null); if (state.failed) return d;
                            }

                            }
                            break;
                        case 2 :
                            // ANMLTree.g:130:58: Parameters
                            {
                            match(input,Parameters,FOLLOW_Parameters_in_type_spec375); if (state.failed) return d;

                            }
                            break;

                    }


                    match(input, Token.UP, null); if (state.failed) return d;

                    }
                    break;
                case 2 :
                    // ANMLTree.g:132:4: ^( TypeRef builtinType ( set )? )
                    {
                    match(input,TypeRef,FOLLOW_TypeRef_in_type_spec389); if (state.failed) return d;

                    match(input, Token.DOWN, null); if (state.failed) return d;
                    pushFollow(FOLLOW_builtinType_in_type_spec391);
                    builtinType6=builtinType();

                    state._fsp--;
                    if (state.failed) return d;
                    if ( state.backtracking==0 ) {
                      d =domain.getType(builtinType6);
                    }
                    // ANMLTree.g:133:8: ( set )?
                    int alt6=2;
                    int LA6_0 = input.LA(1);

                    if ( ((LA6_0>=Enum && LA6_0<=Range)) ) {
                        alt6=1;
                    }
                    switch (alt6) {
                        case 1 :
                            // ANMLTree.g:133:9: set
                            {
                            pushFollow(FOLLOW_set_in_type_spec404);
                            set7=set();

                            state._fsp--;
                            if (state.failed) return d;
                            if ( state.backtracking==0 ) {
                              d =d.constrain(set7);
                            }

                            }
                            break;

                    }


                    match(input, Token.UP, null); if (state.failed) return d;

                    }
                    break;
                case 3 :
                    // ANMLTree.g:135:4: ^( TypeRef id ( set )? )
                    {
                    match(input,TypeRef,FOLLOW_TypeRef_in_type_spec420); if (state.failed) return d;

                    match(input, Token.DOWN, null); if (state.failed) return d;
                    pushFollow(FOLLOW_id_in_type_spec422);
                    id8=id();

                    state._fsp--;
                    if (state.failed) return d;
                    if ( state.backtracking==0 ) {
                      d =((S_scope)S_stack.peek()).d.resolveType(id8);
                    }
                    // ANMLTree.g:136:11: ( set )?
                    int alt7=2;
                    int LA7_0 = input.LA(1);

                    if ( ((LA7_0>=Enum && LA7_0<=Range)) ) {
                        alt7=1;
                    }
                    switch (alt7) {
                        case 1 :
                            // ANMLTree.g:136:12: set
                            {
                            pushFollow(FOLLOW_set_in_type_spec438);
                            set9=set();

                            state._fsp--;
                            if (state.failed) return d;
                            if ( state.backtracking==0 ) {

                                        	d =d.constrain(set9);
                                        	if (d instanceof ExtensibleType) {
                              	          	Enumeration<? extends Identifier<?,?>> values = (Enumeration<? extends Identifier<?,?>>) set9.values();
                              	          	for (Identifier i : values) {
                              	          		((S_scope)S_stack.peek()).d.addSymbol(i);
                              	          	}
                              	          }
                                        
                            }

                            }
                            break;

                    }


                    match(input, Token.UP, null); if (state.failed) return d;

                    }
                    break;
                case 4 :
                    // ANMLTree.g:146:4: enumeration
                    {
                    pushFollow(FOLLOW_enumeration_in_type_spec453);
                    enumeration10=enumeration();

                    state._fsp--;
                    if (state.failed) return d;
                    if ( state.backtracking==0 ) {

                      			c = (enumeration10!=null?enumeration10.constraint:null);
                      			switch ((enumeration10!=null?enumeration10.typeCode:null)) {
                      			case Object:
                      	          	Enumeration<ObjectLiteral> objectValues = (Enumeration<ObjectLiteral>) c;
                      				d = new ObjectType(((S_scope)S_stack.peek()).d,objectValues);
                      	          	for (Identifier<?,?> i : objectValues) {
                      	          		((S_scope)S_stack.peek()).d.addSymbol(i);
                      	          	}
                      			break;
                      			case Symbol:
                                		Enumeration<SymbolLiteral> symbolValues = (Enumeration<SymbolLiteral>) c;
                      				d = new SymbolType(symbolValues);
                      	          	for (Identifier<?,?> i : symbolValues) {
                      	          		((S_scope)S_stack.peek()).d.addSymbol(i);
                      	          	}			break;
                      			case Vector:
                      				d = new VectorType(c);
                      			break;
                      			default:
                      				d = new PrimitiveType((enumeration10!=null?enumeration10.typeCode:null),c);
                      			}
                      		
                    }

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return d;
    }
    // $ANTLR end "type_spec"


    // $ANTLR start "type_decl"
    // ANMLTree.g:173:1: type_decl : ^( Type id ( Assign | ^( Assign type_spec ) ) ( LessThan | ^( LessThan (t= type_ref )* ) ) ( With | ^( With ( object_block[p] )* ) ) ) ;
    public final void type_decl() throws RecognitionException {
        Type t = null;

        SimpleString id11 = null;

        Type type_spec12 = null;


         Type d=null; ObjectType p=null; SymbolType q=null; boolean symbol = false; boolean object = false; 
        try {
            // ANMLTree.g:175:2: ( ^( Type id ( Assign | ^( Assign type_spec ) ) ( LessThan | ^( LessThan (t= type_ref )* ) ) ( With | ^( With ( object_block[p] )* ) ) ) )
            // ANMLTree.g:175:4: ^( Type id ( Assign | ^( Assign type_spec ) ) ( LessThan | ^( LessThan (t= type_ref )* ) ) ( With | ^( With ( object_block[p] )* ) ) )
            {
            match(input,Type,FOLLOW_Type_in_type_decl473); if (state.failed) return ;

            match(input, Token.DOWN, null); if (state.failed) return ;
            pushFollow(FOLLOW_id_in_type_decl475);
            id11=id();

            state._fsp--;
            if (state.failed) return ;
            if ( state.backtracking==0 ) {

              			if (((S_scope)S_stack.peek()).d.getType(id11) != null)
              				System.err.println("Error: Type \"" + id11 + "\" redefined.");
              			//else System.err.println(id11);
              	 	
            }
            // ANMLTree.g:180:3: ( Assign | ^( Assign type_spec ) )
            int alt9=2;
            int LA9_0 = input.LA(1);

            if ( (LA9_0==Assign) ) {
                int LA9_1 = input.LA(2);

                if ( (LA9_1==DOWN) ) {
                    alt9=2;
                }
                else if ( (LA9_1==LessThan) ) {
                    alt9=1;
                }
                else {
                    if (state.backtracking>0) {state.failed=true; return ;}
                    NoViableAltException nvae =
                        new NoViableAltException("", 9, 1, input);

                    throw nvae;
                }
            }
            else {
                if (state.backtracking>0) {state.failed=true; return ;}
                NoViableAltException nvae =
                    new NoViableAltException("", 9, 0, input);

                throw nvae;
            }
            switch (alt9) {
                case 1 :
                    // ANMLTree.g:180:5: Assign
                    {
                    match(input,Assign,FOLLOW_Assign_in_type_decl483); if (state.failed) return ;
                    if ( state.backtracking==0 ) {

                      				p = new ObjectType(((S_scope)S_stack.peek()).d,id11);
                      				q = new SymbolType(id11);
                      			
                    }

                    }
                    break;
                case 2 :
                    // ANMLTree.g:184:5: ^( Assign type_spec )
                    {
                    match(input,Assign,FOLLOW_Assign_in_type_decl492); if (state.failed) return ;

                    match(input, Token.DOWN, null); if (state.failed) return ;
                    pushFollow(FOLLOW_type_spec_in_type_decl494);
                    type_spec12=type_spec();

                    state._fsp--;
                    if (state.failed) return ;

                    match(input, Token.UP, null); if (state.failed) return ;
                    if ( state.backtracking==0 ) {

                      			  d = type_spec12;
                      			  if (d.name() == null) {
                      				  d.name(id11);
                      			  } else {
                      				  // aliasing.  could do something better than cloning.
                      				  d = d.clone();
                      				  d.name(id11);
                      			  }
                      			  if (d.typeCode() == TypeCode.Object) {
                      			  	object = true;
                      				  (p=(ObjectType) d).setParent(((S_scope)S_stack.peek()).d);
                      			  } else if (d.typeCode() == TypeCode.Symbol) {
                      			  	symbol = true;
                      			  	q = (SymbolType) d;
                      			  }
                      			
                    }

                    }
                    break;

            }

            // ANMLTree.g:202:3: ( LessThan | ^( LessThan (t= type_ref )* ) )
            int alt11=2;
            int LA11_0 = input.LA(1);

            if ( (LA11_0==LessThan) ) {
                int LA11_1 = input.LA(2);

                if ( (LA11_1==DOWN) ) {
                    alt11=2;
                }
                else if ( (LA11_1==With) ) {
                    alt11=1;
                }
                else {
                    if (state.backtracking>0) {state.failed=true; return ;}
                    NoViableAltException nvae =
                        new NoViableAltException("", 11, 1, input);

                    throw nvae;
                }
            }
            else {
                if (state.backtracking>0) {state.failed=true; return ;}
                NoViableAltException nvae =
                    new NoViableAltException("", 11, 0, input);

                throw nvae;
            }
            switch (alt11) {
                case 1 :
                    // ANMLTree.g:202:5: LessThan
                    {
                    match(input,LessThan,FOLLOW_LessThan_in_type_decl508); if (state.failed) return ;

                    }
                    break;
                case 2 :
                    // ANMLTree.g:203:5: ^( LessThan (t= type_ref )* )
                    {
                    match(input,LessThan,FOLLOW_LessThan_in_type_decl515); if (state.failed) return ;

                    if ( input.LA(1)==Token.DOWN ) {
                        match(input, Token.DOWN, null); if (state.failed) return ;
                        // ANMLTree.g:203:16: (t= type_ref )*
                        loop10:
                        do {
                            int alt10=2;
                            int LA10_0 = input.LA(1);

                            if ( (LA10_0==TypeRef) ) {
                                alt10=1;
                            }


                            switch (alt10) {
                        	case 1 :
                        	    // ANMLTree.g:203:17: t= type_ref
                        	    {
                        	    pushFollow(FOLLOW_type_ref_in_type_decl520);
                        	    t=type_ref();

                        	    state._fsp--;
                        	    if (state.failed) return ;
                        	    if ( state.backtracking==0 ) {

                        	      						if (t.typeCode() == TypeCode.Object) {
                        	      							if (symbol) {
                        	      								System.err.println("Symbols and Objects are disjoint types: " + id11 + ".");
                        	      								symbol = false;
                        	      							}
                        	      							object = true;
                        	      							p.extend((ObjectType)t);
                        	      						}
                        	      						else if (t.typeCode() == TypeCode.Symbol) {
                        	      							if (object) {
                        	      								System.err.println("Symbols and Objects are disjoint types: " + id11 + ".");
                        	      								object = false;
                        	      							}
                        	      							symbol = true;
                        	      							q.extend((SymbolType)t);
                        	      						} else {
                        	      							System.err.println("Type: " + t.id() + " is not extensible.");
                        	      						}
                        	      					
                        	    }

                        	    }
                        	    break;

                        	default :
                        	    break loop10;
                            }
                        } while (true);


                        match(input, Token.UP, null); if (state.failed) return ;
                    }

                    }
                    break;

            }

            // ANMLTree.g:226:3: ( With | ^( With ( object_block[p] )* ) )
            int alt13=2;
            int LA13_0 = input.LA(1);

            if ( (LA13_0==With) ) {
                int LA13_1 = input.LA(2);

                if ( (LA13_1==DOWN) ) {
                    alt13=2;
                }
                else if ( (LA13_1==UP) ) {
                    alt13=1;
                }
                else {
                    if (state.backtracking>0) {state.failed=true; return ;}
                    NoViableAltException nvae =
                        new NoViableAltException("", 13, 1, input);

                    throw nvae;
                }
            }
            else {
                if (state.backtracking>0) {state.failed=true; return ;}
                NoViableAltException nvae =
                    new NoViableAltException("", 13, 0, input);

                throw nvae;
            }
            switch (alt13) {
                case 1 :
                    // ANMLTree.g:226:5: With
                    {
                    match(input,With,FOLLOW_With_in_type_decl544); if (state.failed) return ;
                    if ( state.backtracking==0 ) {

                      	  		if (d == null) {
                      	  			if (symbol)
                      	  				d = q;
                      	  			else
                      	  				d = p;
                      	  		}
                      			((S_scope)S_stack.peek()).d.addType(d);
                      	  	
                    }

                    }
                    break;
                case 2 :
                    // ANMLTree.g:235:5: ^( With ( object_block[p] )* )
                    {
                    match(input,With,FOLLOW_With_in_type_decl553); if (state.failed) return ;

                    if ( state.backtracking==0 ) {

                      				if (symbol) {
                      					System.err.println("Symbols and Objects are disjoint types: " + id11 + ".");
                      					symbol = false;
                      				}
                      				object = true;
                      				d = p;
                      				((S_scope)S_stack.peek()).d.addType(d);
                      			
                    }

                    if ( input.LA(1)==Token.DOWN ) {
                        match(input, Token.DOWN, null); if (state.failed) return ;
                        // ANMLTree.g:244:4: ( object_block[p] )*
                        loop12:
                        do {
                            int alt12=2;
                            int LA12_0 = input.LA(1);

                            if ( (LA12_0==Block) ) {
                                alt12=1;
                            }


                            switch (alt12) {
                        	case 1 :
                        	    // ANMLTree.g:244:4: object_block[p]
                        	    {
                        	    pushFollow(FOLLOW_object_block_in_type_decl560);
                        	    object_block(p);

                        	    state._fsp--;
                        	    if (state.failed) return ;

                        	    }
                        	    break;

                        	default :
                        	    break loop12;
                            }
                        } while (true);


                        match(input, Token.UP, null); if (state.failed) return ;
                    }

                    }
                    break;

            }


            match(input, Token.UP, null); if (state.failed) return ;

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "type_decl"


    // $ANTLR start "type_refine"
    // ANMLTree.g:249:1: type_refine : ^( TypeRefine r= type_ref ( ^( Assign type_spec ) | ^( LessThan t= type_ref ) | ^( With object_block[p] ) | ( id )+ ) ) ;
    public final void type_refine() throws RecognitionException {
        ANMLToken TypeRefine13=null;
        Type r = null;

        Type t = null;

        Type type_spec14 = null;

        SimpleString id15 = null;


         Type d; ExtensibleType o=null; ObjectType p=null; SymbolType q=null;
        try {
            // ANMLTree.g:251:2: ( ^( TypeRefine r= type_ref ( ^( Assign type_spec ) | ^( LessThan t= type_ref ) | ^( With object_block[p] ) | ( id )+ ) ) )
            // ANMLTree.g:251:4: ^( TypeRefine r= type_ref ( ^( Assign type_spec ) | ^( LessThan t= type_ref ) | ^( With object_block[p] ) | ( id )+ ) )
            {
            TypeRefine13=(ANMLToken)match(input,TypeRefine,FOLLOW_TypeRefine_in_type_refine586); if (state.failed) return ;

            match(input, Token.DOWN, null); if (state.failed) return ;
            pushFollow(FOLLOW_type_ref_in_type_refine590);
            r=type_ref();

            state._fsp--;
            if (state.failed) return ;
            if ( state.backtracking==0 ) {

              			d = r;
              			if (d.name() == null)
              				System.err.println("Error: Cannot refine anonymous types");
              			// well, actually, you can, it just doesn't do any good
              			if (d.typeCode() != TypeCode.Object && d.typeCode() != TypeCode.Symbol) {
              				System.err.println("Error (line " + TypeRefine13.getLine() + "): " + d.name() + " is not an extensible type.");				
              			}
              			else {
              				o = (ExtensibleType) d;
              				if (o.typeCode() == TypeCode.Object) 
              					p = (ObjectType) o;
              				else
              					q = (SymbolType) o;
              			}
              	 	
            }
            // ANMLTree.g:267:2: ( ^( Assign type_spec ) | ^( LessThan t= type_ref ) | ^( With object_block[p] ) | ( id )+ )
            int alt15=4;
            switch ( input.LA(1) ) {
            case Assign:
                {
                alt15=1;
                }
                break;
            case LessThan:
                {
                alt15=2;
                }
                break;
            case With:
                {
                alt15=3;
                }
                break;
            case ID:
            case This:
                {
                alt15=4;
                }
                break;
            default:
                if (state.backtracking>0) {state.failed=true; return ;}
                NoViableAltException nvae =
                    new NoViableAltException("", 15, 0, input);

                throw nvae;
            }

            switch (alt15) {
                case 1 :
                    // ANMLTree.g:267:4: ^( Assign type_spec )
                    {
                    match(input,Assign,FOLLOW_Assign_in_type_refine598); if (state.failed) return ;

                    match(input, Token.DOWN, null); if (state.failed) return ;
                    pushFollow(FOLLOW_type_spec_in_type_refine600);
                    type_spec14=type_spec();

                    state._fsp--;
                    if (state.failed) return ;

                    match(input, Token.UP, null); if (state.failed) return ;
                    if ( state.backtracking==0 ) {

                      			d = type_spec14;
                      			if (o != null) {
                      				if (d.typeCode() == TypeCode.Object)
                      					p.set(((ObjectType)d).members());
                      				else if (d.typeCode() == TypeCode.Symbol)
                      					q.set(((SymbolType)d).members());
                      			}
                      		
                    }

                    }
                    break;
                case 2 :
                    // ANMLTree.g:276:4: ^( LessThan t= type_ref )
                    {
                    match(input,LessThan,FOLLOW_LessThan_in_type_refine610); if (state.failed) return ;

                    match(input, Token.DOWN, null); if (state.failed) return ;
                    pushFollow(FOLLOW_type_ref_in_type_refine614);
                    t=type_ref();

                    state._fsp--;
                    if (state.failed) return ;
                    if ( state.backtracking==0 ) {

                      			d = t;
                      			if (o != null) {
                      				if (d.typeCode() == TypeCode.Object)
                      					p.extend((ObjectType)d);
                      				else if (d.typeCode() == TypeCode.Symbol)
                      					q.extend((SymbolType)d);
                      			}
                      		
                    }

                    match(input, Token.UP, null); if (state.failed) return ;

                    }
                    break;
                case 3 :
                    // ANMLTree.g:285:4: ^( With object_block[p] )
                    {
                    match(input,With,FOLLOW_With_in_type_refine623); if (state.failed) return ;

                    match(input, Token.DOWN, null); if (state.failed) return ;
                    pushFollow(FOLLOW_object_block_in_type_refine625);
                    object_block(p);

                    state._fsp--;
                    if (state.failed) return ;

                    match(input, Token.UP, null); if (state.failed) return ;

                    }
                    break;
                case 4 :
                    // ANMLTree.g:286:5: ( id )+
                    {
                    // ANMLTree.g:286:5: ( id )+
                    int cnt14=0;
                    loop14:
                    do {
                        int alt14=2;
                        int LA14_0 = input.LA(1);

                        if ( ((LA14_0>=ID && LA14_0<=This)) ) {
                            alt14=1;
                        }


                        switch (alt14) {
                    	case 1 :
                    	    // ANMLTree.g:286:6: id
                    	    {
                    	    pushFollow(FOLLOW_id_in_type_refine634);
                    	    id15=id();

                    	    state._fsp--;
                    	    if (state.failed) return ;
                    	    if ( state.backtracking==0 ) {

                    	      			if (p != null) {
                    	      				ObjectLiteral l = new ObjectLiteral(id15);
                    	      				((S_scope)S_stack.peek()).d.addSymbol(l);
                    	      				p.add(l);
                    	      			} else if (q != null) {
                    	      				SymbolLiteral m = new SymbolLiteral(id15);
                    	      				((S_scope)S_stack.peek()).d.addSymbol(m);
                    	      				q.add(m);
                    	      			} else {
                    	      				SymbolLiteral m = new SymbolLiteral(id15);
                    	      				((S_scope)S_stack.peek()).d.addSymbol(m);
                    	      			}
                    	      	   	
                    	    }

                    	    }
                    	    break;

                    	default :
                    	    if ( cnt14 >= 1 ) break loop14;
                    	    if (state.backtracking>0) {state.failed=true; return ;}
                                EarlyExitException eee =
                                    new EarlyExitException(14, input);
                                throw eee;
                        }
                        cnt14++;
                    } while (true);


                    }
                    break;

            }


            match(input, Token.UP, null); if (state.failed) return ;

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "type_refine"


    // $ANTLR start "type_ref"
    // ANMLTree.g:313:1: type_ref returns [Type d] : ( ^( TypeRef builtinType ) | ^( TypeRef builtinType set ) | ^( TypeRef id ) );
    public final Type type_ref() throws RecognitionException {
        Type d = null;

        TypeCode builtinType16 = null;

        TypeCode builtinType17 = null;

        Constraint set18 = null;

        SimpleString id19 = null;


        Constraint c;
        try {
            // ANMLTree.g:315:2: ( ^( TypeRef builtinType ) | ^( TypeRef builtinType set ) | ^( TypeRef id ) )
            int alt16=3;
            alt16 = dfa16.predict(input);
            switch (alt16) {
                case 1 :
                    // ANMLTree.g:315:4: ^( TypeRef builtinType )
                    {
                    match(input,TypeRef,FOLLOW_TypeRef_in_type_ref677); if (state.failed) return d;

                    match(input, Token.DOWN, null); if (state.failed) return d;
                    pushFollow(FOLLOW_builtinType_in_type_ref679);
                    builtinType16=builtinType();

                    state._fsp--;
                    if (state.failed) return d;

                    match(input, Token.UP, null); if (state.failed) return d;
                    if ( state.backtracking==0 ) {
                       
                      			d = domain.getType(builtinType16); 
                      			//System.out.println("TypeRef: " + d);
                      		
                    }

                    }
                    break;
                case 2 :
                    // ANMLTree.g:319:4: ^( TypeRef builtinType set )
                    {
                    match(input,TypeRef,FOLLOW_TypeRef_in_type_ref688); if (state.failed) return d;

                    match(input, Token.DOWN, null); if (state.failed) return d;
                    pushFollow(FOLLOW_builtinType_in_type_ref690);
                    builtinType17=builtinType();

                    state._fsp--;
                    if (state.failed) return d;
                    pushFollow(FOLLOW_set_in_type_ref692);
                    set18=set();

                    state._fsp--;
                    if (state.failed) return d;

                    match(input, Token.UP, null); if (state.failed) return d;
                    if ( state.backtracking==0 ) {

                      			d = domain.getType(builtinType17).constrain(set18);
                      			//System.out.println("TypeRef: " + d);
                      		
                    }

                    }
                    break;
                case 3 :
                    // ANMLTree.g:323:4: ^( TypeRef id )
                    {
                    match(input,TypeRef,FOLLOW_TypeRef_in_type_ref701); if (state.failed) return d;

                    match(input, Token.DOWN, null); if (state.failed) return d;
                    pushFollow(FOLLOW_id_in_type_ref703);
                    id19=id();

                    state._fsp--;
                    if (state.failed) return d;

                    match(input, Token.UP, null); if (state.failed) return d;
                    if ( state.backtracking==0 ) {
                       
                      			d = ((S_scope)S_stack.peek()).d.resolveType(id19); 
                      			if (d == null) {
                      				d = domain.objectType;
                      				System.err.println("Type: " + id19 + " is undeclared at its first reference.");
                      			}
                      			//System.out.println("TypeRef: " + id19 + " " + d);
                      		
                    }

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return d;
    }
    // $ANTLR end "type_ref"


    // $ANTLR start "const_decl"
    // ANMLTree.g:334:1: const_decl : ( ^( Constant id type_ref (i= expression )? ) | ^( ConstantFunction id type_ref ( ^( Parameters term_arg_decl_list[f] ) | Parameters ) ) );
    public final void const_decl() throws RecognitionException {
        ANMLToken Constant21=null;
        ANMLToken ConstantFunction24=null;
        Expression<?,?> i = null;

        SimpleString id20 = null;

        Type type_ref22 = null;

        SimpleString id23 = null;

        Type type_ref25 = null;


        Expression<?,?> init=null;ConstantFunction f=null;
        try {
            // ANMLTree.g:336:2: ( ^( Constant id type_ref (i= expression )? ) | ^( ConstantFunction id type_ref ( ^( Parameters term_arg_decl_list[f] ) | Parameters ) ) )
            int alt19=2;
            int LA19_0 = input.LA(1);

            if ( (LA19_0==Constant) ) {
                alt19=1;
            }
            else if ( (LA19_0==ConstantFunction) ) {
                alt19=2;
            }
            else {
                if (state.backtracking>0) {state.failed=true; return ;}
                NoViableAltException nvae =
                    new NoViableAltException("", 19, 0, input);

                throw nvae;
            }
            switch (alt19) {
                case 1 :
                    // ANMLTree.g:336:4: ^( Constant id type_ref (i= expression )? )
                    {
                    Constant21=(ANMLToken)match(input,Constant,FOLLOW_Constant_in_const_decl748); if (state.failed) return ;

                    match(input, Token.DOWN, null); if (state.failed) return ;
                    pushFollow(FOLLOW_id_in_const_decl750);
                    id20=id();

                    state._fsp--;
                    if (state.failed) return ;
                    if ( state.backtracking==0 ) {

                      			if (((S_scope)S_stack.peek()).d.getSymbol(id20) != null)
                      				System.err.println("Error (line " + Constant21.getLine() + "): \"" + id20 + "\" redefined.");
                      		
                    }
                    pushFollow(FOLLOW_type_ref_in_const_decl756);
                    type_ref22=type_ref();

                    state._fsp--;
                    if (state.failed) return ;
                    // ANMLTree.g:340:12: (i= expression )?
                    int alt17=2;
                    int LA17_0 = input.LA(1);

                    if ( ((LA17_0>=LabelRef && LA17_0<=Access)||LA17_0==Label||(LA17_0>=Bra && LA17_0<=Ket)||LA17_0==TimedExpr||(LA17_0>=ContainsSomeExpr && LA17_0<=ContainsAllExpr)||LA17_0==ExistsExpr||LA17_0==ID||(LA17_0>=LessThan && LA17_0<=Assign)||LA17_0==Undefine||(LA17_0>=NotLog && LA17_0<=Equal)||LA17_0==Duration||(LA17_0>=Change && LA17_0<=Delta)||(LA17_0>=Implies && LA17_0<=Ordered)||(LA17_0>=Start && LA17_0<=GreaterThanE)||LA17_0==ForallExpr) ) {
                        alt17=1;
                    }
                    switch (alt17) {
                        case 1 :
                            // ANMLTree.g:340:13: i= expression
                            {
                            pushFollow(FOLLOW_expression_in_const_decl761);
                            i=expression();

                            state._fsp--;
                            if (state.failed) return ;
                            if ( state.backtracking==0 ) {
                              init = i;
                            }

                            }
                            break;

                    }


                    match(input, Token.UP, null); if (state.failed) return ;
                    if ( state.backtracking==0 ) {
                      ((S_scope)S_stack.peek()).d.addConstant(new Constant(id20,type_ref22,init));
                    }

                    }
                    break;
                case 2 :
                    // ANMLTree.g:342:4: ^( ConstantFunction id type_ref ( ^( Parameters term_arg_decl_list[f] ) | Parameters ) )
                    {
                    ConstantFunction24=(ANMLToken)match(input,ConstantFunction,FOLLOW_ConstantFunction_in_const_decl776); if (state.failed) return ;

                    match(input, Token.DOWN, null); if (state.failed) return ;
                    pushFollow(FOLLOW_id_in_const_decl778);
                    id23=id();

                    state._fsp--;
                    if (state.failed) return ;
                    if ( state.backtracking==0 ) {

                      			if (((S_scope)S_stack.peek()).d.getSymbol(id23) != null)
                      				System.err.println("Error (line " + ConstantFunction24.getLine() + "): \"" + id23 + "\" redefined.");
                      		
                    }
                    pushFollow(FOLLOW_type_ref_in_const_decl784);
                    type_ref25=type_ref();

                    state._fsp--;
                    if (state.failed) return ;
                    if ( state.backtracking==0 ) {
                      f=new ConstantFunction(id23,type_ref25);((S_scope)S_stack.peek()).d.addConstantFunction(f);
                    }
                    // ANMLTree.g:347:6: ( ^( Parameters term_arg_decl_list[f] ) | Parameters )
                    int alt18=2;
                    int LA18_0 = input.LA(1);

                    if ( (LA18_0==Parameters) ) {
                        int LA18_1 = input.LA(2);

                        if ( (LA18_1==DOWN) ) {
                            alt18=1;
                        }
                        else if ( (LA18_1==UP) ) {
                            alt18=2;
                        }
                        else {
                            if (state.backtracking>0) {state.failed=true; return ;}
                            NoViableAltException nvae =
                                new NoViableAltException("", 18, 1, input);

                            throw nvae;
                        }
                    }
                    else {
                        if (state.backtracking>0) {state.failed=true; return ;}
                        NoViableAltException nvae =
                            new NoViableAltException("", 18, 0, input);

                        throw nvae;
                    }
                    switch (alt18) {
                        case 1 :
                            // ANMLTree.g:347:7: ^( Parameters term_arg_decl_list[f] )
                            {
                            match(input,Parameters,FOLLOW_Parameters_in_const_decl796); if (state.failed) return ;

                            if ( input.LA(1)==Token.DOWN ) {
                                match(input, Token.DOWN, null); if (state.failed) return ;
                                pushFollow(FOLLOW_term_arg_decl_list_in_const_decl798);
                                term_arg_decl_list(f);

                                state._fsp--;
                                if (state.failed) return ;

                                match(input, Token.UP, null); if (state.failed) return ;
                            }

                            }
                            break;
                        case 2 :
                            // ANMLTree.g:347:45: Parameters
                            {
                            match(input,Parameters,FOLLOW_Parameters_in_const_decl804); if (state.failed) return ;

                            }
                            break;

                    }


                    match(input, Token.UP, null); if (state.failed) return ;

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "const_decl"


    // $ANTLR start "fluent_decl"
    // ANMLTree.g:351:1: fluent_decl : ( ^( Fluent id type_ref (i= expression )? ) | ^( FluentFunction id type_ref ( ^( Parameters term_arg_decl_list[f] ) | Parameters ) ) );
    public final void fluent_decl() throws RecognitionException {
        ANMLToken Fluent27=null;
        ANMLToken FluentFunction30=null;
        Expression<?,?> i = null;

        SimpleString id26 = null;

        Type type_ref28 = null;

        SimpleString id29 = null;

        Type type_ref31 = null;


        Expression<?,?> init=null;FluentFunction f=null;
        try {
            // ANMLTree.g:353:2: ( ^( Fluent id type_ref (i= expression )? ) | ^( FluentFunction id type_ref ( ^( Parameters term_arg_decl_list[f] ) | Parameters ) ) )
            int alt22=2;
            int LA22_0 = input.LA(1);

            if ( (LA22_0==Fluent) ) {
                alt22=1;
            }
            else if ( (LA22_0==FluentFunction) ) {
                alt22=2;
            }
            else {
                if (state.backtracking>0) {state.failed=true; return ;}
                NoViableAltException nvae =
                    new NoViableAltException("", 22, 0, input);

                throw nvae;
            }
            switch (alt22) {
                case 1 :
                    // ANMLTree.g:353:4: ^( Fluent id type_ref (i= expression )? )
                    {
                    Fluent27=(ANMLToken)match(input,Fluent,FOLLOW_Fluent_in_fluent_decl827); if (state.failed) return ;

                    match(input, Token.DOWN, null); if (state.failed) return ;
                    pushFollow(FOLLOW_id_in_fluent_decl829);
                    id26=id();

                    state._fsp--;
                    if (state.failed) return ;
                    if ( state.backtracking==0 ) {

                      			if (((S_scope)S_stack.peek()).d.getSymbol(id26) != null)
                      				System.err.println("Error (line " + Fluent27.getLine() + "): \"" + id26 + "\" redefined.");
                      		
                    }
                    pushFollow(FOLLOW_type_ref_in_fluent_decl835);
                    type_ref28=type_ref();

                    state._fsp--;
                    if (state.failed) return ;
                    // ANMLTree.g:357:12: (i= expression )?
                    int alt20=2;
                    int LA20_0 = input.LA(1);

                    if ( ((LA20_0>=LabelRef && LA20_0<=Access)||LA20_0==Label||(LA20_0>=Bra && LA20_0<=Ket)||LA20_0==TimedExpr||(LA20_0>=ContainsSomeExpr && LA20_0<=ContainsAllExpr)||LA20_0==ExistsExpr||LA20_0==ID||(LA20_0>=LessThan && LA20_0<=Assign)||LA20_0==Undefine||(LA20_0>=NotLog && LA20_0<=Equal)||LA20_0==Duration||(LA20_0>=Change && LA20_0<=Delta)||(LA20_0>=Implies && LA20_0<=Ordered)||(LA20_0>=Start && LA20_0<=GreaterThanE)||LA20_0==ForallExpr) ) {
                        alt20=1;
                    }
                    switch (alt20) {
                        case 1 :
                            // ANMLTree.g:357:13: i= expression
                            {
                            pushFollow(FOLLOW_expression_in_fluent_decl840);
                            i=expression();

                            state._fsp--;
                            if (state.failed) return ;
                            if ( state.backtracking==0 ) {
                              init = i;
                            }

                            }
                            break;

                    }


                    match(input, Token.UP, null); if (state.failed) return ;
                    if ( state.backtracking==0 ) {
                      ((S_scope)S_stack.peek()).d.addFluent(new Fluent(id26,type_ref28,init));
                    }

                    }
                    break;
                case 2 :
                    // ANMLTree.g:359:4: ^( FluentFunction id type_ref ( ^( Parameters term_arg_decl_list[f] ) | Parameters ) )
                    {
                    FluentFunction30=(ANMLToken)match(input,FluentFunction,FOLLOW_FluentFunction_in_fluent_decl855); if (state.failed) return ;

                    match(input, Token.DOWN, null); if (state.failed) return ;
                    pushFollow(FOLLOW_id_in_fluent_decl857);
                    id29=id();

                    state._fsp--;
                    if (state.failed) return ;
                    if ( state.backtracking==0 ) {

                      			if (((S_scope)S_stack.peek()).d.getSymbol(id29) != null)
                      				System.err.println("Error (line " + FluentFunction30.getLine() + "): \"" + id29 + "\" redefined.");
                      		
                    }
                    pushFollow(FOLLOW_type_ref_in_fluent_decl863);
                    type_ref31=type_ref();

                    state._fsp--;
                    if (state.failed) return ;
                    if ( state.backtracking==0 ) {

                      			f=new FluentFunction(id29,type_ref31);
                      			((S_scope)S_stack.peek()).d.addFluentFunction(f);
                      		
                    }
                    // ANMLTree.g:367:6: ( ^( Parameters term_arg_decl_list[f] ) | Parameters )
                    int alt21=2;
                    int LA21_0 = input.LA(1);

                    if ( (LA21_0==Parameters) ) {
                        int LA21_1 = input.LA(2);

                        if ( (LA21_1==DOWN) ) {
                            alt21=1;
                        }
                        else if ( (LA21_1==UP) ) {
                            alt21=2;
                        }
                        else {
                            if (state.backtracking>0) {state.failed=true; return ;}
                            NoViableAltException nvae =
                                new NoViableAltException("", 21, 1, input);

                            throw nvae;
                        }
                    }
                    else {
                        if (state.backtracking>0) {state.failed=true; return ;}
                        NoViableAltException nvae =
                            new NoViableAltException("", 21, 0, input);

                        throw nvae;
                    }
                    switch (alt21) {
                        case 1 :
                            // ANMLTree.g:367:7: ^( Parameters term_arg_decl_list[f] )
                            {
                            match(input,Parameters,FOLLOW_Parameters_in_fluent_decl874); if (state.failed) return ;

                            if ( input.LA(1)==Token.DOWN ) {
                                match(input, Token.DOWN, null); if (state.failed) return ;
                                pushFollow(FOLLOW_term_arg_decl_list_in_fluent_decl876);
                                term_arg_decl_list(f);

                                state._fsp--;
                                if (state.failed) return ;

                                match(input, Token.UP, null); if (state.failed) return ;
                            }

                            }
                            break;
                        case 2 :
                            // ANMLTree.g:367:45: Parameters
                            {
                            match(input,Parameters,FOLLOW_Parameters_in_fluent_decl882); if (state.failed) return ;

                            }
                            break;

                    }


                    match(input, Token.UP, null); if (state.failed) return ;

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "fluent_decl"


    // $ANTLR start "object_block"
    // ANMLTree.g:376:1: object_block[Scope d] : ^( Block types constants fluents actions stmts ) ;
    public final void object_block(Scope d) throws RecognitionException {
        S_stack.push(new S_scope());

        ((S_scope)S_stack.peek()).d =d;
        try {
            // ANMLTree.g:379:3: ( ^( Block types constants fluents actions stmts ) )
            // ANMLTree.g:379:5: ^( Block types constants fluents actions stmts )
            {
            match(input,Block,FOLLOW_Block_in_object_block917); if (state.failed) return ;

            match(input, Token.DOWN, null); if (state.failed) return ;
            pushFollow(FOLLOW_types_in_object_block924);
            types();

            state._fsp--;
            if (state.failed) return ;
            pushFollow(FOLLOW_constants_in_object_block930);
            constants();

            state._fsp--;
            if (state.failed) return ;
            pushFollow(FOLLOW_fluents_in_object_block936);
            fluents();

            state._fsp--;
            if (state.failed) return ;
            pushFollow(FOLLOW_actions_in_object_block942);
            actions();

            state._fsp--;
            if (state.failed) return ;
            pushFollow(FOLLOW_stmts_in_object_block948);
            stmts();

            state._fsp--;
            if (state.failed) return ;

            match(input, Token.UP, null); if (state.failed) return ;

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
            S_stack.pop();

        }
        return ;
    }
    // $ANTLR end "object_block"


    // $ANTLR start "action_decl"
    // ANMLTree.g:392:1: action_decl : ^( Action id ( ^( Parameters scope_arg_decl_list[a] ) | Parameters ) start_parameter[a] ( duration_parameter[a] )? action_block[a] ) ;
    public final void action_decl() throws RecognitionException {
        SimpleString id32 = null;


        Action a=null;
        try {
            // ANMLTree.g:394:1: ( ^( Action id ( ^( Parameters scope_arg_decl_list[a] ) | Parameters ) start_parameter[a] ( duration_parameter[a] )? action_block[a] ) )
            // ANMLTree.g:395:2: ^( Action id ( ^( Parameters scope_arg_decl_list[a] ) | Parameters ) start_parameter[a] ( duration_parameter[a] )? action_block[a] )
            {
            match(input,Action,FOLLOW_Action_in_action_decl974); if (state.failed) return ;

            match(input, Token.DOWN, null); if (state.failed) return ;
            pushFollow(FOLLOW_id_in_action_decl976);
            id32=id();

            state._fsp--;
            if (state.failed) return ;
            if ( state.backtracking==0 ) {

              			a=((S_scope)S_stack.peek()).d.resolveAction(id32);
              			assert a != null;
              			a.setParent(((S_scope)S_stack.peek()).d); // just in case scope pointer was wrong
              		
            }
            // ANMLTree.g:400:3: ( ^( Parameters scope_arg_decl_list[a] ) | Parameters )
            int alt23=2;
            int LA23_0 = input.LA(1);

            if ( (LA23_0==Parameters) ) {
                int LA23_1 = input.LA(2);

                if ( (LA23_1==DOWN) ) {
                    alt23=1;
                }
                else if ( (LA23_1==Types||LA23_1==Duration) ) {
                    alt23=2;
                }
                else {
                    if (state.backtracking>0) {state.failed=true; return ;}
                    NoViableAltException nvae =
                        new NoViableAltException("", 23, 1, input);

                    throw nvae;
                }
            }
            else {
                if (state.backtracking>0) {state.failed=true; return ;}
                NoViableAltException nvae =
                    new NoViableAltException("", 23, 0, input);

                throw nvae;
            }
            switch (alt23) {
                case 1 :
                    // ANMLTree.g:400:4: ^( Parameters scope_arg_decl_list[a] )
                    {
                    match(input,Parameters,FOLLOW_Parameters_in_action_decl984); if (state.failed) return ;

                    if ( input.LA(1)==Token.DOWN ) {
                        match(input, Token.DOWN, null); if (state.failed) return ;
                        pushFollow(FOLLOW_scope_arg_decl_list_in_action_decl986);
                        scope_arg_decl_list(a);

                        state._fsp--;
                        if (state.failed) return ;

                        match(input, Token.UP, null); if (state.failed) return ;
                    }

                    }
                    break;
                case 2 :
                    // ANMLTree.g:400:43: Parameters
                    {
                    match(input,Parameters,FOLLOW_Parameters_in_action_decl992); if (state.failed) return ;

                    }
                    break;

            }

            pushFollow(FOLLOW_start_parameter_in_action_decl998);
            start_parameter(a);

            state._fsp--;
            if (state.failed) return ;
            // ANMLTree.g:402:3: ( duration_parameter[a] )?
            int alt24=2;
            int LA24_0 = input.LA(1);

            if ( (LA24_0==Duration) ) {
                alt24=1;
            }
            switch (alt24) {
                case 1 :
                    // ANMLTree.g:402:3: duration_parameter[a]
                    {
                    pushFollow(FOLLOW_duration_parameter_in_action_decl1003);
                    duration_parameter(a);

                    state._fsp--;
                    if (state.failed) return ;

                    }
                    break;

            }

            pushFollow(FOLLOW_action_block_in_action_decl1011);
            action_block(a);

            state._fsp--;
            if (state.failed) return ;

            match(input, Token.UP, null); if (state.failed) return ;

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "action_decl"


    // $ANTLR start "start_parameter"
    // ANMLTree.g:407:1: start_parameter[Action a] : ;
    public final void start_parameter(Action a) throws RecognitionException {

        	Parameter<SimpleFloat> s = new Parameter<SimpleFloat>(IntervalImp.startName,Unit.floatType); 
        	a.addParameter(s); 
        	a.start.init = s;

        try {
            // ANMLTree.g:413:1: ()
            // ANMLTree.g:414:1: 
            {
            }

        }
        finally {
        }
        return ;
    }
    // $ANTLR end "start_parameter"


    // $ANTLR start "duration_parameter"
    // ANMLTree.g:416:1: duration_parameter[Action a] : Duration ;
    public final void duration_parameter(Action a) throws RecognitionException {

        	Parameter<SimpleFloat> d = new Parameter<SimpleFloat>(IntervalImp.durationName,Unit.floatType); 
        	a.addParameter(d); 
        	a.duration.init = d; 

        try {
            // ANMLTree.g:422:1: ( Duration )
            // ANMLTree.g:423:2: Duration
            {
            match(input,Duration,FOLLOW_Duration_in_duration_parameter1063); if (state.failed) return ;

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "duration_parameter"


    // $ANTLR start "action_block"
    // ANMLTree.g:426:1: action_block[Action a] : types constants fluents actions stmts decompositions ;
    public final void action_block(Action a) throws RecognitionException {
        S_stack.push(new S_scope());
        A_stack.push(new A_scope());
        I_stack.push(new I_scope());

        ((S_scope)S_stack.peek()).d =a;((A_scope)A_stack.peek()).d =a;((I_scope)I_stack.peek()).i =a;
        try {
            // ANMLTree.g:429:1: ( types constants fluents actions stmts decompositions )
            // ANMLTree.g:430:2: types constants fluents actions stmts decompositions
            {
            pushFollow(FOLLOW_types_in_action_block1091);
            types();

            state._fsp--;
            if (state.failed) return ;
            pushFollow(FOLLOW_constants_in_action_block1094);
            constants();

            state._fsp--;
            if (state.failed) return ;
            pushFollow(FOLLOW_fluents_in_action_block1097);
            fluents();

            state._fsp--;
            if (state.failed) return ;
            pushFollow(FOLLOW_actions_in_action_block1100);
            actions();

            state._fsp--;
            if (state.failed) return ;
            pushFollow(FOLLOW_stmts_in_action_block1103);
            stmts();

            state._fsp--;
            if (state.failed) return ;
            pushFollow(FOLLOW_decompositions_in_action_block1106);
            decompositions();

            state._fsp--;
            if (state.failed) return ;

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
            S_stack.pop();
            A_stack.pop();
            I_stack.pop();

        }
        return ;
    }
    // $ANTLR end "action_block"


    // $ANTLR start "types"
    // ANMLTree.g:438:1: types : ( ^( Types ( type_decl | type_refine )* ) | Types );
    public final void types() throws RecognitionException {
        try {
            // ANMLTree.g:438:7: ( ^( Types ( type_decl | type_refine )* ) | Types )
            int alt26=2;
            int LA26_0 = input.LA(1);

            if ( (LA26_0==Types) ) {
                int LA26_1 = input.LA(2);

                if ( (LA26_1==DOWN) ) {
                    alt26=1;
                }
                else if ( (LA26_1==Constants) ) {
                    alt26=2;
                }
                else {
                    if (state.backtracking>0) {state.failed=true; return ;}
                    NoViableAltException nvae =
                        new NoViableAltException("", 26, 1, input);

                    throw nvae;
                }
            }
            else {
                if (state.backtracking>0) {state.failed=true; return ;}
                NoViableAltException nvae =
                    new NoViableAltException("", 26, 0, input);

                throw nvae;
            }
            switch (alt26) {
                case 1 :
                    // ANMLTree.g:439:2: ^( Types ( type_decl | type_refine )* )
                    {
                    match(input,Types,FOLLOW_Types_in_types1117); if (state.failed) return ;

                    if ( input.LA(1)==Token.DOWN ) {
                        match(input, Token.DOWN, null); if (state.failed) return ;
                        // ANMLTree.g:439:10: ( type_decl | type_refine )*
                        loop25:
                        do {
                            int alt25=3;
                            int LA25_0 = input.LA(1);

                            if ( (LA25_0==Type) ) {
                                alt25=1;
                            }
                            else if ( (LA25_0==TypeRefine) ) {
                                alt25=2;
                            }


                            switch (alt25) {
                        	case 1 :
                        	    // ANMLTree.g:439:11: type_decl
                        	    {
                        	    pushFollow(FOLLOW_type_decl_in_types1120);
                        	    type_decl();

                        	    state._fsp--;
                        	    if (state.failed) return ;

                        	    }
                        	    break;
                        	case 2 :
                        	    // ANMLTree.g:439:21: type_refine
                        	    {
                        	    pushFollow(FOLLOW_type_refine_in_types1122);
                        	    type_refine();

                        	    state._fsp--;
                        	    if (state.failed) return ;

                        	    }
                        	    break;

                        	default :
                        	    break loop25;
                            }
                        } while (true);


                        match(input, Token.UP, null); if (state.failed) return ;
                    }

                    }
                    break;
                case 2 :
                    // ANMLTree.g:440:4: Types
                    {
                    match(input,Types,FOLLOW_Types_in_types1130); if (state.failed) return ;

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "types"


    // $ANTLR start "constants"
    // ANMLTree.g:442:1: constants : ( ^( Constants ( const_decl )* ) | Constants );
    public final void constants() throws RecognitionException {
        try {
            // ANMLTree.g:442:11: ( ^( Constants ( const_decl )* ) | Constants )
            int alt28=2;
            int LA28_0 = input.LA(1);

            if ( (LA28_0==Constants) ) {
                int LA28_1 = input.LA(2);

                if ( (LA28_1==DOWN) ) {
                    alt28=1;
                }
                else if ( (LA28_1==Fluents) ) {
                    alt28=2;
                }
                else {
                    if (state.backtracking>0) {state.failed=true; return ;}
                    NoViableAltException nvae =
                        new NoViableAltException("", 28, 1, input);

                    throw nvae;
                }
            }
            else {
                if (state.backtracking>0) {state.failed=true; return ;}
                NoViableAltException nvae =
                    new NoViableAltException("", 28, 0, input);

                throw nvae;
            }
            switch (alt28) {
                case 1 :
                    // ANMLTree.g:443:2: ^( Constants ( const_decl )* )
                    {
                    match(input,Constants,FOLLOW_Constants_in_constants1140); if (state.failed) return ;

                    if ( input.LA(1)==Token.DOWN ) {
                        match(input, Token.DOWN, null); if (state.failed) return ;
                        // ANMLTree.g:443:14: ( const_decl )*
                        loop27:
                        do {
                            int alt27=2;
                            int LA27_0 = input.LA(1);

                            if ( ((LA27_0>=Constant && LA27_0<=ConstantFunction)) ) {
                                alt27=1;
                            }


                            switch (alt27) {
                        	case 1 :
                        	    // ANMLTree.g:443:14: const_decl
                        	    {
                        	    pushFollow(FOLLOW_const_decl_in_constants1142);
                        	    const_decl();

                        	    state._fsp--;
                        	    if (state.failed) return ;

                        	    }
                        	    break;

                        	default :
                        	    break loop27;
                            }
                        } while (true);


                        match(input, Token.UP, null); if (state.failed) return ;
                    }

                    }
                    break;
                case 2 :
                    // ANMLTree.g:444:4: Constants
                    {
                    match(input,Constants,FOLLOW_Constants_in_constants1150); if (state.failed) return ;

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "constants"


    // $ANTLR start "fluents"
    // ANMLTree.g:446:1: fluents : ( ^( Fluents ( fluent_decl )* ) | Fluents );
    public final void fluents() throws RecognitionException {
        try {
            // ANMLTree.g:446:9: ( ^( Fluents ( fluent_decl )* ) | Fluents )
            int alt30=2;
            int LA30_0 = input.LA(1);

            if ( (LA30_0==Fluents) ) {
                int LA30_1 = input.LA(2);

                if ( (LA30_1==DOWN) ) {
                    alt30=1;
                }
                else if ( (LA30_1==Actions) ) {
                    alt30=2;
                }
                else {
                    if (state.backtracking>0) {state.failed=true; return ;}
                    NoViableAltException nvae =
                        new NoViableAltException("", 30, 1, input);

                    throw nvae;
                }
            }
            else {
                if (state.backtracking>0) {state.failed=true; return ;}
                NoViableAltException nvae =
                    new NoViableAltException("", 30, 0, input);

                throw nvae;
            }
            switch (alt30) {
                case 1 :
                    // ANMLTree.g:447:2: ^( Fluents ( fluent_decl )* )
                    {
                    match(input,Fluents,FOLLOW_Fluents_in_fluents1160); if (state.failed) return ;

                    if ( input.LA(1)==Token.DOWN ) {
                        match(input, Token.DOWN, null); if (state.failed) return ;
                        // ANMLTree.g:447:12: ( fluent_decl )*
                        loop29:
                        do {
                            int alt29=2;
                            int LA29_0 = input.LA(1);

                            if ( ((LA29_0>=Fluent && LA29_0<=FluentFunction)) ) {
                                alt29=1;
                            }


                            switch (alt29) {
                        	case 1 :
                        	    // ANMLTree.g:447:12: fluent_decl
                        	    {
                        	    pushFollow(FOLLOW_fluent_decl_in_fluents1162);
                        	    fluent_decl();

                        	    state._fsp--;
                        	    if (state.failed) return ;

                        	    }
                        	    break;

                        	default :
                        	    break loop29;
                            }
                        } while (true);


                        match(input, Token.UP, null); if (state.failed) return ;
                    }

                    }
                    break;
                case 2 :
                    // ANMLTree.g:448:4: Fluents
                    {
                    match(input,Fluents,FOLLOW_Fluents_in_fluents1170); if (state.failed) return ;

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "fluents"


    // $ANTLR start "actions"
    // ANMLTree.g:451:1: actions : ( ^( Actions ( action_decl )* ) | Actions );
    public final void actions() throws RecognitionException {
        try {
            // ANMLTree.g:451:9: ( ^( Actions ( action_decl )* ) | Actions )
            int alt32=2;
            int LA32_0 = input.LA(1);

            if ( (LA32_0==Actions) ) {
                int LA32_1 = input.LA(2);

                if ( (LA32_1==DOWN) ) {
                    alt32=1;
                }
                else if ( (LA32_1==Stmts) ) {
                    alt32=2;
                }
                else {
                    if (state.backtracking>0) {state.failed=true; return ;}
                    NoViableAltException nvae =
                        new NoViableAltException("", 32, 1, input);

                    throw nvae;
                }
            }
            else {
                if (state.backtracking>0) {state.failed=true; return ;}
                NoViableAltException nvae =
                    new NoViableAltException("", 32, 0, input);

                throw nvae;
            }
            switch (alt32) {
                case 1 :
                    // ANMLTree.g:452:2: ^( Actions ( action_decl )* )
                    {
                    match(input,Actions,FOLLOW_Actions_in_actions1181); if (state.failed) return ;

                    if ( input.LA(1)==Token.DOWN ) {
                        match(input, Token.DOWN, null); if (state.failed) return ;
                        // ANMLTree.g:452:12: ( action_decl )*
                        loop31:
                        do {
                            int alt31=2;
                            int LA31_0 = input.LA(1);

                            if ( (LA31_0==Action) ) {
                                alt31=1;
                            }


                            switch (alt31) {
                        	case 1 :
                        	    // ANMLTree.g:452:12: action_decl
                        	    {
                        	    pushFollow(FOLLOW_action_decl_in_actions1183);
                        	    action_decl();

                        	    state._fsp--;
                        	    if (state.failed) return ;

                        	    }
                        	    break;

                        	default :
                        	    break loop31;
                            }
                        } while (true);


                        match(input, Token.UP, null); if (state.failed) return ;
                    }

                    }
                    break;
                case 2 :
                    // ANMLTree.g:453:4: Actions
                    {
                    match(input,Actions,FOLLOW_Actions_in_actions1190); if (state.failed) return ;

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "actions"


    // $ANTLR start "stmts"
    // ANMLTree.g:456:1: stmts : ( ^( Stmts ( stmts_helper )* ) | Stmts );
    public final void stmts() throws RecognitionException {
        try {
            // ANMLTree.g:456:7: ( ^( Stmts ( stmts_helper )* ) | Stmts )
            int alt34=2;
            int LA34_0 = input.LA(1);

            if ( (LA34_0==Stmts) ) {
                int LA34_1 = input.LA(2);

                if ( (LA34_1==DOWN) ) {
                    alt34=1;
                }
                else if ( (LA34_1==UP||LA34_1==Decompositions) ) {
                    alt34=2;
                }
                else {
                    if (state.backtracking>0) {state.failed=true; return ;}
                    NoViableAltException nvae =
                        new NoViableAltException("", 34, 1, input);

                    throw nvae;
                }
            }
            else {
                if (state.backtracking>0) {state.failed=true; return ;}
                NoViableAltException nvae =
                    new NoViableAltException("", 34, 0, input);

                throw nvae;
            }
            switch (alt34) {
                case 1 :
                    // ANMLTree.g:457:2: ^( Stmts ( stmts_helper )* )
                    {
                    match(input,Stmts,FOLLOW_Stmts_in_stmts1201); if (state.failed) return ;

                    if ( input.LA(1)==Token.DOWN ) {
                        match(input, Token.DOWN, null); if (state.failed) return ;
                        // ANMLTree.g:457:10: ( stmts_helper )*
                        loop33:
                        do {
                            int alt33=2;
                            int LA33_0 = input.LA(1);

                            if ( (LA33_0==Block||(LA33_0>=LabelRef && LA33_0<=Access)||LA33_0==Label||(LA33_0>=Bra && LA33_0<=Ket)||(LA33_0>=Chain && LA33_0<=ContainsAllExpr)||(LA33_0>=ForAllStmt && LA33_0<=WhenElse)||LA33_0==ID||(LA33_0>=LessThan && LA33_0<=Assign)||LA33_0==Undefine||(LA33_0>=NotLog && LA33_0<=Equal)||LA33_0==Duration||(LA33_0>=Change && LA33_0<=Delta)||(LA33_0>=Implies && LA33_0<=Ordered)||(LA33_0>=Start && LA33_0<=GreaterThanE)||LA33_0==ForallExpr) ) {
                                alt33=1;
                            }


                            switch (alt33) {
                        	case 1 :
                        	    // ANMLTree.g:457:10: stmts_helper
                        	    {
                        	    pushFollow(FOLLOW_stmts_helper_in_stmts1203);
                        	    stmts_helper();

                        	    state._fsp--;
                        	    if (state.failed) return ;

                        	    }
                        	    break;

                        	default :
                        	    break loop33;
                            }
                        } while (true);


                        match(input, Token.UP, null); if (state.failed) return ;
                    }

                    }
                    break;
                case 2 :
                    // ANMLTree.g:458:4: Stmts
                    {
                    match(input,Stmts,FOLLOW_Stmts_in_stmts1211); if (state.failed) return ;

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "stmts"


    // $ANTLR start "stmts_helper"
    // ANMLTree.g:460:1: stmts_helper : stmt ;
    public final void stmts_helper() throws RecognitionException {
        Statement stmt33 = null;


        try {
            // ANMLTree.g:460:14: ( stmt )
            // ANMLTree.g:460:16: stmt
            {
            pushFollow(FOLLOW_stmt_in_stmts_helper1219);
            stmt33=stmt();

            state._fsp--;
            if (state.failed) return ;
            if ( state.backtracking==0 ) {
              ((S_scope)S_stack.peek()).d.addStatement(stmt33);
            }

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "stmts_helper"


    // $ANTLR start "decompositions"
    // ANMLTree.g:462:1: decompositions : ( ^( Decompositions ( decomps_helper )* ) | Decompositions );
    public final void decompositions() throws RecognitionException {
        try {
            // ANMLTree.g:462:16: ( ^( Decompositions ( decomps_helper )* ) | Decompositions )
            int alt36=2;
            int LA36_0 = input.LA(1);

            if ( (LA36_0==Decompositions) ) {
                int LA36_1 = input.LA(2);

                if ( (LA36_1==DOWN) ) {
                    alt36=1;
                }
                else if ( (LA36_1==UP) ) {
                    alt36=2;
                }
                else {
                    if (state.backtracking>0) {state.failed=true; return ;}
                    NoViableAltException nvae =
                        new NoViableAltException("", 36, 1, input);

                    throw nvae;
                }
            }
            else {
                if (state.backtracking>0) {state.failed=true; return ;}
                NoViableAltException nvae =
                    new NoViableAltException("", 36, 0, input);

                throw nvae;
            }
            switch (alt36) {
                case 1 :
                    // ANMLTree.g:463:2: ^( Decompositions ( decomps_helper )* )
                    {
                    match(input,Decompositions,FOLLOW_Decompositions_in_decompositions1232); if (state.failed) return ;

                    if ( input.LA(1)==Token.DOWN ) {
                        match(input, Token.DOWN, null); if (state.failed) return ;
                        // ANMLTree.g:463:19: ( decomps_helper )*
                        loop35:
                        do {
                            int alt35=2;
                            int LA35_0 = input.LA(1);

                            if ( (LA35_0==Block) ) {
                                alt35=1;
                            }


                            switch (alt35) {
                        	case 1 :
                        	    // ANMLTree.g:463:19: decomps_helper
                        	    {
                        	    pushFollow(FOLLOW_decomps_helper_in_decompositions1234);
                        	    decomps_helper();

                        	    state._fsp--;
                        	    if (state.failed) return ;

                        	    }
                        	    break;

                        	default :
                        	    break loop35;
                            }
                        } while (true);


                        match(input, Token.UP, null); if (state.failed) return ;
                    }

                    }
                    break;
                case 2 :
                    // ANMLTree.g:464:4: Decompositions
                    {
                    match(input,Decompositions,FOLLOW_Decompositions_in_decompositions1242); if (state.failed) return ;

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "decompositions"


    // $ANTLR start "decomps_helper"
    // ANMLTree.g:466:1: decomps_helper : decomp[$S::d] ;
    public final void decomps_helper() throws RecognitionException {
        Decomposition decomp34 = null;


        try {
            // ANMLTree.g:466:16: ( decomp[$S::d] )
            // ANMLTree.g:466:18: decomp[$S::d]
            {
            pushFollow(FOLLOW_decomp_in_decomps_helper1250);
            decomp34=decomp(((S_scope)S_stack.peek()).d);

            state._fsp--;
            if (state.failed) return ;
            if ( state.backtracking==0 ) {
              ((A_scope)A_stack.peek()).d.addDecomposition(decomp34);
            }

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "decomps_helper"


    // $ANTLR start "decomp"
    // ANMLTree.g:468:1: decomp[Scope parent] returns [Decomposition s] : ^( Block types constants fluents actions stmts ) ;
    public final Decomposition decomp(Scope parent) throws RecognitionException {
        S_stack.push(new S_scope());

        Decomposition s = null;

        ANMLToken Block35=null;

        try {
            // ANMLTree.g:470:2: ( ^( Block types constants fluents actions stmts ) )
            // ANMLTree.g:470:4: ^( Block types constants fluents actions stmts )
            {
            Block35=(ANMLToken)match(input,Block,FOLLOW_Block_in_decomp1274); if (state.failed) return s;

            if ( state.backtracking==0 ) {
               ((S_scope)S_stack.peek()).d =s=new Decomposition(parent,Block35.textSimple); 
            }

            match(input, Token.DOWN, null); if (state.failed) return s;
            pushFollow(FOLLOW_types_in_decomp1281);
            types();

            state._fsp--;
            if (state.failed) return s;
            pushFollow(FOLLOW_constants_in_decomp1285);
            constants();

            state._fsp--;
            if (state.failed) return s;
            pushFollow(FOLLOW_fluents_in_decomp1289);
            fluents();

            state._fsp--;
            if (state.failed) return s;
            pushFollow(FOLLOW_actions_in_decomp1293);
            actions();

            state._fsp--;
            if (state.failed) return s;
            pushFollow(FOLLOW_stmts_in_decomp1297);
            stmts();

            state._fsp--;
            if (state.failed) return s;

            match(input, Token.UP, null); if (state.failed) return s;

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
            S_stack.pop();

        }
        return s;
    }
    // $ANTLR end "decomp"


    // $ANTLR start "block"
    // ANMLTree.g:479:1: block[Scope parent] returns [Block s] : ^( Block types constants fluents actions stmts ) ;
    public final Block block(Scope parent) throws RecognitionException {
        S_stack.push(new S_scope());

        Block s = null;

        ANMLToken Block36=null;

        try {
            // ANMLTree.g:481:2: ( ^( Block types constants fluents actions stmts ) )
            // ANMLTree.g:481:4: ^( Block types constants fluents actions stmts )
            {
            Block36=(ANMLToken)match(input,Block,FOLLOW_Block_in_block1323); if (state.failed) return s;

            if ( state.backtracking==0 ) {
              ((S_scope)S_stack.peek()).d =s=new Block(parent,Block36.textSimple);
            }

            match(input, Token.DOWN, null); if (state.failed) return s;
            pushFollow(FOLLOW_types_in_block1330);
            types();

            state._fsp--;
            if (state.failed) return s;
            pushFollow(FOLLOW_constants_in_block1334);
            constants();

            state._fsp--;
            if (state.failed) return s;
            pushFollow(FOLLOW_fluents_in_block1338);
            fluents();

            state._fsp--;
            if (state.failed) return s;
            pushFollow(FOLLOW_actions_in_block1342);
            actions();

            state._fsp--;
            if (state.failed) return s;
            pushFollow(FOLLOW_stmts_in_block1346);
            stmts();

            state._fsp--;
            if (state.failed) return s;

            match(input, Token.UP, null); if (state.failed) return s;

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
            S_stack.pop();

        }
        return s;
    }
    // $ANTLR end "block"


    // $ANTLR start "sub_block"
    // ANMLTree.g:490:1: sub_block[Block b] : ^( Block types constants fluents actions stmts ) ;
    public final void sub_block(Block b) throws RecognitionException {
        S_stack.push(new S_scope());

        ((S_scope)S_stack.peek()).d =b;
        try {
            // ANMLTree.g:493:2: ( ^( Block types constants fluents actions stmts ) )
            // ANMLTree.g:493:4: ^( Block types constants fluents actions stmts )
            {
            match(input,Block,FOLLOW_Block_in_sub_block1372); if (state.failed) return ;

            match(input, Token.DOWN, null); if (state.failed) return ;
            pushFollow(FOLLOW_types_in_sub_block1377);
            types();

            state._fsp--;
            if (state.failed) return ;
            pushFollow(FOLLOW_constants_in_sub_block1381);
            constants();

            state._fsp--;
            if (state.failed) return ;
            pushFollow(FOLLOW_fluents_in_sub_block1385);
            fluents();

            state._fsp--;
            if (state.failed) return ;
            pushFollow(FOLLOW_actions_in_sub_block1389);
            actions();

            state._fsp--;
            if (state.failed) return ;
            pushFollow(FOLLOW_stmts_in_sub_block1393);
            stmts();

            state._fsp--;
            if (state.failed) return ;

            match(input, Token.UP, null); if (state.failed) return ;

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
            S_stack.pop();

        }
        return ;
    }
    // $ANTLR end "sub_block"


    // $ANTLR start "stmt"
    // ANMLTree.g:502:1: stmt returns [Statement s] : ( simple_stmt | block[$S::d] );
    public final Statement stmt() throws RecognitionException {
        Statement s = null;

        Statement simple_stmt37 = null;

        Block block38 = null;


        try {
            // ANMLTree.g:503:2: ( simple_stmt | block[$S::d] )
            int alt37=2;
            int LA37_0 = input.LA(1);

            if ( ((LA37_0>=LabelRef && LA37_0<=Access)||LA37_0==Label||(LA37_0>=Bra && LA37_0<=Ket)||(LA37_0>=Chain && LA37_0<=ContainsAllExpr)||(LA37_0>=ForAllStmt && LA37_0<=WhenElse)||LA37_0==ID||(LA37_0>=LessThan && LA37_0<=Assign)||LA37_0==Undefine||(LA37_0>=NotLog && LA37_0<=Equal)||LA37_0==Duration||(LA37_0>=Change && LA37_0<=Delta)||(LA37_0>=Implies && LA37_0<=Ordered)||(LA37_0>=Start && LA37_0<=GreaterThanE)||LA37_0==ForallExpr) ) {
                alt37=1;
            }
            else if ( (LA37_0==Block) ) {
                alt37=2;
            }
            else {
                if (state.backtracking>0) {state.failed=true; return s;}
                NoViableAltException nvae =
                    new NoViableAltException("", 37, 0, input);

                throw nvae;
            }
            switch (alt37) {
                case 1 :
                    // ANMLTree.g:503:4: simple_stmt
                    {
                    pushFollow(FOLLOW_simple_stmt_in_stmt1412);
                    simple_stmt37=simple_stmt();

                    state._fsp--;
                    if (state.failed) return s;
                    if ( state.backtracking==0 ) {
                       s=simple_stmt37; 
                    }

                    }
                    break;
                case 2 :
                    // ANMLTree.g:504:4: block[$S::d]
                    {
                    pushFollow(FOLLOW_block_in_stmt1419);
                    block38=block(((S_scope)S_stack.peek()).d);

                    state._fsp--;
                    if (state.failed) return s;
                    if ( state.backtracking==0 ) {
                       s=block38; 
                    }

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return s;
    }
    // $ANTLR end "stmt"


    // $ANTLR start "timed_stmt"
    // ANMLTree.g:507:1: timed_stmt[Interval i] returns [Statement s] : stmt ;
    public final Statement timed_stmt(Interval i) throws RecognitionException {
        I_stack.push(new I_scope());

        Statement s = null;

        Statement stmt39 = null;


         ((I_scope)I_stack.peek()).i = i;
        try {
            // ANMLTree.g:510:2: ( stmt )
            // ANMLTree.g:510:4: stmt
            {
            pushFollow(FOLLOW_stmt_in_timed_stmt1447);
            stmt39=stmt();

            state._fsp--;
            if (state.failed) return s;
            if ( state.backtracking==0 ) {
              s = stmt39;
            }

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
            I_stack.pop();

        }
        return s;
    }
    // $ANTLR end "timed_stmt"


    // $ANTLR start "simple_stmt"
    // ANMLTree.g:514:1: simple_stmt returns [Statement s] : ( ^( When guard= expression then= stmt ) | ^( WhenElse guard= expression then= stmt elsel= stmt ) | ^( ForAllStmt ^( Parameters scope_arg_decl_list[forall] ) ( sub_block[forall] | sDo= simple_stmt ) ) | ^( ExistsStmt ^( Parameters scope_arg_decl_list[exists] ) ( sub_block[exists] | sHolds= simple_stmt ) ) | ^( ContainsSomeStmt interval[ts] timed_stmt[ts] ) | ^( ContainsAllStmt stmt ) | ^( TimedStmt interval[ts] timed_stmt[ts] ) | ^( Chain chain_stmt ) | expr= expression );
    public final Statement simple_stmt() throws RecognitionException {
        Statement s = null;

        ANMLToken ForAllStmt40=null;
        ANMLToken ExistsStmt41=null;
        Expression<?,?> guard = null;

        Statement then = null;

        Statement elsel = null;

        Statement sDo = null;

        Statement sHolds = null;

        Expression<?,?> expr = null;

        Statement timed_stmt42 = null;

        Chain chain_stmt43 = null;


         
        	ForAll forall=null; 
        	Exists exists=null; 
        	s = null; 
        	Expression<SimpleBoolean,?> g;
        	TimedStatement ts=null;

        try {
            // ANMLTree.g:522:2: ( ^( When guard= expression then= stmt ) | ^( WhenElse guard= expression then= stmt elsel= stmt ) | ^( ForAllStmt ^( Parameters scope_arg_decl_list[forall] ) ( sub_block[forall] | sDo= simple_stmt ) ) | ^( ExistsStmt ^( Parameters scope_arg_decl_list[exists] ) ( sub_block[exists] | sHolds= simple_stmt ) ) | ^( ContainsSomeStmt interval[ts] timed_stmt[ts] ) | ^( ContainsAllStmt stmt ) | ^( TimedStmt interval[ts] timed_stmt[ts] ) | ^( Chain chain_stmt ) | expr= expression )
            int alt40=9;
            switch ( input.LA(1) ) {
            case When:
                {
                alt40=1;
                }
                break;
            case WhenElse:
                {
                alt40=2;
                }
                break;
            case ForAllStmt:
                {
                alt40=3;
                }
                break;
            case ExistsStmt:
                {
                alt40=4;
                }
                break;
            case ContainsSomeStmt:
                {
                alt40=5;
                }
                break;
            case ContainsAllStmt:
                {
                alt40=6;
                }
                break;
            case TimedStmt:
                {
                alt40=7;
                }
                break;
            case Chain:
                {
                alt40=8;
                }
                break;
            case LabelRef:
            case Ref:
            case Bind:
            case Access:
            case Label:
            case Bra:
            case Ket:
            case TimedExpr:
            case ContainsSomeExpr:
            case ContainsAllExpr:
            case ExistsExpr:
            case ID:
            case LessThan:
            case Assign:
            case Undefine:
            case NotLog:
            case NotBit:
            case EqualLog:
            case Equal:
            case Duration:
            case Change:
            case Produce:
            case Consume:
            case Lend:
            case Use:
            case Within:
            case SetAssign:
            case Skip:
            case Delta:
            case Implies:
            case XorLog:
            case OrLog:
            case AndLog:
            case XorBit:
            case Plus:
            case Minus:
            case OrBit:
            case Times:
            case Divide:
            case AndBit:
            case Unordered:
            case Ordered:
            case Start:
            case End:
            case INT:
            case FLOAT:
            case STRING:
            case True:
            case False:
            case Infinity:
            case NotEqual:
            case GreaterThan:
            case LessThanE:
            case GreaterThanE:
            case ForallExpr:
                {
                alt40=9;
                }
                break;
            default:
                if (state.backtracking>0) {state.failed=true; return s;}
                NoViableAltException nvae =
                    new NoViableAltException("", 40, 0, input);

                throw nvae;
            }

            switch (alt40) {
                case 1 :
                    // ANMLTree.g:522:4: ^( When guard= expression then= stmt )
                    {
                    match(input,When,FOLLOW_When_in_simple_stmt1470); if (state.failed) return s;

                    match(input, Token.DOWN, null); if (state.failed) return s;
                    pushFollow(FOLLOW_expression_in_simple_stmt1474);
                    guard=expression();

                    state._fsp--;
                    if (state.failed) return s;
                    pushFollow(FOLLOW_stmt_in_simple_stmt1478);
                    then=stmt();

                    state._fsp--;
                    if (state.failed) return s;

                    match(input, Token.UP, null); if (state.failed) return s;
                    if ( state.backtracking==0 ) {
                      s =new WhenStatement((Expression<SimpleBoolean,?>) guard,then);
                    }

                    }
                    break;
                case 2 :
                    // ANMLTree.g:523:4: ^( WhenElse guard= expression then= stmt elsel= stmt )
                    {
                    match(input,WhenElse,FOLLOW_WhenElse_in_simple_stmt1487); if (state.failed) return s;

                    match(input, Token.DOWN, null); if (state.failed) return s;
                    pushFollow(FOLLOW_expression_in_simple_stmt1491);
                    guard=expression();

                    state._fsp--;
                    if (state.failed) return s;
                    pushFollow(FOLLOW_stmt_in_simple_stmt1495);
                    then=stmt();

                    state._fsp--;
                    if (state.failed) return s;
                    pushFollow(FOLLOW_stmt_in_simple_stmt1499);
                    elsel=stmt();

                    state._fsp--;
                    if (state.failed) return s;

                    match(input, Token.UP, null); if (state.failed) return s;
                    if ( state.backtracking==0 ) {
                      s =new WhenElseStatement((Expression<SimpleBoolean,?>) guard,then,elsel);
                    }

                    }
                    break;
                case 3 :
                    // ANMLTree.g:524:4: ^( ForAllStmt ^( Parameters scope_arg_decl_list[forall] ) ( sub_block[forall] | sDo= simple_stmt ) )
                    {
                    ForAllStmt40=(ANMLToken)match(input,ForAllStmt,FOLLOW_ForAllStmt_in_simple_stmt1508); if (state.failed) return s;

                    if ( state.backtracking==0 ) {
                      s = forall = new ForAll(((S_scope)S_stack.peek()).d,ForAllStmt40.getSimpleText());
                    }

                    match(input, Token.DOWN, null); if (state.failed) return s;
                    match(input,Parameters,FOLLOW_Parameters_in_simple_stmt1519); if (state.failed) return s;

                    if ( input.LA(1)==Token.DOWN ) {
                        match(input, Token.DOWN, null); if (state.failed) return s;
                        pushFollow(FOLLOW_scope_arg_decl_list_in_simple_stmt1521);
                        scope_arg_decl_list(forall);

                        state._fsp--;
                        if (state.failed) return s;

                        match(input, Token.UP, null); if (state.failed) return s;
                    }
                    // ANMLTree.g:526:6: ( sub_block[forall] | sDo= simple_stmt )
                    int alt38=2;
                    int LA38_0 = input.LA(1);

                    if ( (LA38_0==Block) ) {
                        alt38=1;
                    }
                    else if ( ((LA38_0>=LabelRef && LA38_0<=Access)||LA38_0==Label||(LA38_0>=Bra && LA38_0<=Ket)||(LA38_0>=Chain && LA38_0<=ContainsAllExpr)||(LA38_0>=ForAllStmt && LA38_0<=WhenElse)||LA38_0==ID||(LA38_0>=LessThan && LA38_0<=Assign)||LA38_0==Undefine||(LA38_0>=NotLog && LA38_0<=Equal)||LA38_0==Duration||(LA38_0>=Change && LA38_0<=Delta)||(LA38_0>=Implies && LA38_0<=Ordered)||(LA38_0>=Start && LA38_0<=GreaterThanE)||LA38_0==ForallExpr) ) {
                        alt38=2;
                    }
                    else {
                        if (state.backtracking>0) {state.failed=true; return s;}
                        NoViableAltException nvae =
                            new NoViableAltException("", 38, 0, input);

                        throw nvae;
                    }
                    switch (alt38) {
                        case 1 :
                            // ANMLTree.g:526:8: sub_block[forall]
                            {
                            pushFollow(FOLLOW_sub_block_in_simple_stmt1533);
                            sub_block(forall);

                            state._fsp--;
                            if (state.failed) return s;

                            }
                            break;
                        case 2 :
                            // ANMLTree.g:527:8: sDo= simple_stmt
                            {
                            pushFollow(FOLLOW_simple_stmt_in_simple_stmt1545);
                            sDo=simple_stmt();

                            state._fsp--;
                            if (state.failed) return s;
                            if ( state.backtracking==0 ) {
                              forall.addStatement(sDo);
                            }

                            }
                            break;

                    }


                    match(input, Token.UP, null); if (state.failed) return s;

                    }
                    break;
                case 4 :
                    // ANMLTree.g:530:4: ^( ExistsStmt ^( Parameters scope_arg_decl_list[exists] ) ( sub_block[exists] | sHolds= simple_stmt ) )
                    {
                    ExistsStmt41=(ANMLToken)match(input,ExistsStmt,FOLLOW_ExistsStmt_in_simple_stmt1565); if (state.failed) return s;

                    if ( state.backtracking==0 ) {
                      s = exists = new Exists(((S_scope)S_stack.peek()).d,ExistsStmt41.getSimpleText());
                    }

                    match(input, Token.DOWN, null); if (state.failed) return s;
                    match(input,Parameters,FOLLOW_Parameters_in_simple_stmt1576); if (state.failed) return s;

                    if ( input.LA(1)==Token.DOWN ) {
                        match(input, Token.DOWN, null); if (state.failed) return s;
                        pushFollow(FOLLOW_scope_arg_decl_list_in_simple_stmt1578);
                        scope_arg_decl_list(exists);

                        state._fsp--;
                        if (state.failed) return s;

                        match(input, Token.UP, null); if (state.failed) return s;
                    }
                    // ANMLTree.g:532:6: ( sub_block[exists] | sHolds= simple_stmt )
                    int alt39=2;
                    int LA39_0 = input.LA(1);

                    if ( (LA39_0==Block) ) {
                        alt39=1;
                    }
                    else if ( ((LA39_0>=LabelRef && LA39_0<=Access)||LA39_0==Label||(LA39_0>=Bra && LA39_0<=Ket)||(LA39_0>=Chain && LA39_0<=ContainsAllExpr)||(LA39_0>=ForAllStmt && LA39_0<=WhenElse)||LA39_0==ID||(LA39_0>=LessThan && LA39_0<=Assign)||LA39_0==Undefine||(LA39_0>=NotLog && LA39_0<=Equal)||LA39_0==Duration||(LA39_0>=Change && LA39_0<=Delta)||(LA39_0>=Implies && LA39_0<=Ordered)||(LA39_0>=Start && LA39_0<=GreaterThanE)||LA39_0==ForallExpr) ) {
                        alt39=2;
                    }
                    else {
                        if (state.backtracking>0) {state.failed=true; return s;}
                        NoViableAltException nvae =
                            new NoViableAltException("", 39, 0, input);

                        throw nvae;
                    }
                    switch (alt39) {
                        case 1 :
                            // ANMLTree.g:532:8: sub_block[exists]
                            {
                            pushFollow(FOLLOW_sub_block_in_simple_stmt1589);
                            sub_block(exists);

                            state._fsp--;
                            if (state.failed) return s;

                            }
                            break;
                        case 2 :
                            // ANMLTree.g:533:8: sHolds= simple_stmt
                            {
                            pushFollow(FOLLOW_simple_stmt_in_simple_stmt1603);
                            sHolds=simple_stmt();

                            state._fsp--;
                            if (state.failed) return s;
                            if ( state.backtracking==0 ) {
                              exists.addStatement(sHolds);
                            }

                            }
                            break;

                    }


                    match(input, Token.UP, null); if (state.failed) return s;

                    }
                    break;
                case 5 :
                    // ANMLTree.g:536:4: ^( ContainsSomeStmt interval[ts] timed_stmt[ts] )
                    {
                    match(input,ContainsSomeStmt,FOLLOW_ContainsSomeStmt_in_simple_stmt1623); if (state.failed) return s;

                    match(input, Token.DOWN, null); if (state.failed) return s;
                    pushFollow(FOLLOW_interval_in_simple_stmt1625);
                    interval(ts);

                    state._fsp--;
                    if (state.failed) return s;
                    pushFollow(FOLLOW_timed_stmt_in_simple_stmt1628);
                    timed_stmt(ts);

                    state._fsp--;
                    if (state.failed) return s;

                    match(input, Token.UP, null); if (state.failed) return s;

                    }
                    break;
                case 6 :
                    // ANMLTree.g:537:4: ^( ContainsAllStmt stmt )
                    {
                    match(input,ContainsAllStmt,FOLLOW_ContainsAllStmt_in_simple_stmt1636); if (state.failed) return s;

                    match(input, Token.DOWN, null); if (state.failed) return s;
                    pushFollow(FOLLOW_stmt_in_simple_stmt1638);
                    stmt();

                    state._fsp--;
                    if (state.failed) return s;

                    match(input, Token.UP, null); if (state.failed) return s;

                    }
                    break;
                case 7 :
                    // ANMLTree.g:538:4: ^( TimedStmt interval[ts] timed_stmt[ts] )
                    {
                    match(input,TimedStmt,FOLLOW_TimedStmt_in_simple_stmt1645); if (state.failed) return s;

                    if ( state.backtracking==0 ) {
                      s = ts = new TimedStatement();
                    }

                    match(input, Token.DOWN, null); if (state.failed) return s;
                    pushFollow(FOLLOW_interval_in_simple_stmt1653);
                    interval(ts);

                    state._fsp--;
                    if (state.failed) return s;
                    pushFollow(FOLLOW_timed_stmt_in_simple_stmt1656);
                    timed_stmt42=timed_stmt(ts);

                    state._fsp--;
                    if (state.failed) return s;
                    if ( state.backtracking==0 ) {
                      ts.s = timed_stmt42;
                    }

                    match(input, Token.UP, null); if (state.failed) return s;

                    }
                    break;
                case 8 :
                    // ANMLTree.g:541:4: ^( Chain chain_stmt )
                    {
                    match(input,Chain,FOLLOW_Chain_in_simple_stmt1669); if (state.failed) return s;

                    match(input, Token.DOWN, null); if (state.failed) return s;
                    pushFollow(FOLLOW_chain_stmt_in_simple_stmt1671);
                    chain_stmt43=chain_stmt();

                    state._fsp--;
                    if (state.failed) return s;

                    match(input, Token.UP, null); if (state.failed) return s;
                    if ( state.backtracking==0 ) {
                      s = chain_stmt43;
                    }

                    }
                    break;
                case 9 :
                    // ANMLTree.g:542:4: expr= expression
                    {
                    pushFollow(FOLLOW_expression_in_simple_stmt1681);
                    expr=expression();

                    state._fsp--;
                    if (state.failed) return s;
                    if ( state.backtracking==0 ) {
                       s = expr; 
                    }

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return s;
    }
    // $ANTLR end "simple_stmt"


    // $ANTLR start "chain_stmt"
    // ANMLTree.g:545:1: chain_stmt returns [Chain c] : interval[c] ref ( ^( Equal r= expression ) | ^( NotEqual r= expression ) | ^( LessThan r= expression ) | ^( GreaterThan r= expression ) | ^( LessThanE r= expression ) | ^( GreaterThanE r= expression ) | ^( Assign r= expression ) | ^( Change r= expression ) | ^( Lend r= expression ) | ^( Use r= expression ) | ^( Produce r= expression ) | ^( Consume r= expression ) | ^( SetAssign set ) | ^( Within set ) | Undefine | Skip )+ ;
    public final Chain chain_stmt() throws RecognitionException {
        Chain c = null;

        Expression<?,?> r = null;

        OpUnary ref44 = null;



        	c = new Chain();
        	Expression<?,?> l=null; 

        try {
            // ANMLTree.g:550:5: ( interval[c] ref ( ^( Equal r= expression ) | ^( NotEqual r= expression ) | ^( LessThan r= expression ) | ^( GreaterThan r= expression ) | ^( LessThanE r= expression ) | ^( GreaterThanE r= expression ) | ^( Assign r= expression ) | ^( Change r= expression ) | ^( Lend r= expression ) | ^( Use r= expression ) | ^( Produce r= expression ) | ^( Consume r= expression ) | ^( SetAssign set ) | ^( Within set ) | Undefine | Skip )+ )
            // ANMLTree.g:550:7: interval[c] ref ( ^( Equal r= expression ) | ^( NotEqual r= expression ) | ^( LessThan r= expression ) | ^( GreaterThan r= expression ) | ^( LessThanE r= expression ) | ^( GreaterThanE r= expression ) | ^( Assign r= expression ) | ^( Change r= expression ) | ^( Lend r= expression ) | ^( Use r= expression ) | ^( Produce r= expression ) | ^( Consume r= expression ) | ^( SetAssign set ) | ^( Within set ) | Undefine | Skip )+
            {
            pushFollow(FOLLOW_interval_in_chain_stmt1705);
            interval(c);

            state._fsp--;
            if (state.failed) return c;
            pushFollow(FOLLOW_ref_in_chain_stmt1708);
            ref44=ref();

            state._fsp--;
            if (state.failed) return c;
            if ( state.backtracking==0 ) {
              l = ref44;
            }
            // ANMLTree.g:551:2: ( ^( Equal r= expression ) | ^( NotEqual r= expression ) | ^( LessThan r= expression ) | ^( GreaterThan r= expression ) | ^( LessThanE r= expression ) | ^( GreaterThanE r= expression ) | ^( Assign r= expression ) | ^( Change r= expression ) | ^( Lend r= expression ) | ^( Use r= expression ) | ^( Produce r= expression ) | ^( Consume r= expression ) | ^( SetAssign set ) | ^( Within set ) | Undefine | Skip )+
            int cnt41=0;
            loop41:
            do {
                int alt41=17;
                switch ( input.LA(1) ) {
                case Equal:
                    {
                    alt41=1;
                    }
                    break;
                case NotEqual:
                    {
                    alt41=2;
                    }
                    break;
                case LessThan:
                    {
                    alt41=3;
                    }
                    break;
                case GreaterThan:
                    {
                    alt41=4;
                    }
                    break;
                case LessThanE:
                    {
                    alt41=5;
                    }
                    break;
                case GreaterThanE:
                    {
                    alt41=6;
                    }
                    break;
                case Assign:
                    {
                    alt41=7;
                    }
                    break;
                case Change:
                    {
                    alt41=8;
                    }
                    break;
                case Lend:
                    {
                    alt41=9;
                    }
                    break;
                case Use:
                    {
                    alt41=10;
                    }
                    break;
                case Produce:
                    {
                    alt41=11;
                    }
                    break;
                case Consume:
                    {
                    alt41=12;
                    }
                    break;
                case SetAssign:
                    {
                    alt41=13;
                    }
                    break;
                case Within:
                    {
                    alt41=14;
                    }
                    break;
                case Undefine:
                    {
                    alt41=15;
                    }
                    break;
                case Skip:
                    {
                    alt41=16;
                    }
                    break;

                }

                switch (alt41) {
            	case 1 :
            	    // ANMLTree.g:551:4: ^( Equal r= expression )
            	    {
            	    match(input,Equal,FOLLOW_Equal_in_chain_stmt1716); if (state.failed) return c;

            	    match(input, Token.DOWN, null); if (state.failed) return c;
            	    pushFollow(FOLLOW_expression_in_chain_stmt1720);
            	    r=expression();

            	    state._fsp--;
            	    if (state.failed) return c;

            	    match(input, Token.UP, null); if (state.failed) return c;
            	    if ( state.backtracking==0 ) {

            	      			c.expressions.add(new OpBinary(TypeCode.Boolean,Op.equal,l,r));
            	      		
            	    }

            	    }
            	    break;
            	case 2 :
            	    // ANMLTree.g:554:4: ^( NotEqual r= expression )
            	    {
            	    match(input,NotEqual,FOLLOW_NotEqual_in_chain_stmt1729); if (state.failed) return c;

            	    match(input, Token.DOWN, null); if (state.failed) return c;
            	    pushFollow(FOLLOW_expression_in_chain_stmt1733);
            	    r=expression();

            	    state._fsp--;
            	    if (state.failed) return c;

            	    match(input, Token.UP, null); if (state.failed) return c;
            	    if ( state.backtracking==0 ) {

            	      			c.expressions.add(new OpBinary(TypeCode.Boolean,Op.notEqual,l,r));
            	      		
            	    }

            	    }
            	    break;
            	case 3 :
            	    // ANMLTree.g:557:4: ^( LessThan r= expression )
            	    {
            	    match(input,LessThan,FOLLOW_LessThan_in_chain_stmt1742); if (state.failed) return c;

            	    match(input, Token.DOWN, null); if (state.failed) return c;
            	    pushFollow(FOLLOW_expression_in_chain_stmt1746);
            	    r=expression();

            	    state._fsp--;
            	    if (state.failed) return c;

            	    match(input, Token.UP, null); if (state.failed) return c;
            	    if ( state.backtracking==0 ) {

            	      			c.expressions.add(new OpBinary(TypeCode.Boolean,Op.lessThan,l,r));
            	      		
            	    }

            	    }
            	    break;
            	case 4 :
            	    // ANMLTree.g:560:4: ^( GreaterThan r= expression )
            	    {
            	    match(input,GreaterThan,FOLLOW_GreaterThan_in_chain_stmt1755); if (state.failed) return c;

            	    match(input, Token.DOWN, null); if (state.failed) return c;
            	    pushFollow(FOLLOW_expression_in_chain_stmt1759);
            	    r=expression();

            	    state._fsp--;
            	    if (state.failed) return c;

            	    match(input, Token.UP, null); if (state.failed) return c;
            	    if ( state.backtracking==0 ) {

            	      			c.expressions.add(new OpBinary(TypeCode.Boolean,Op.greaterThan,l,r));
            	      		
            	    }

            	    }
            	    break;
            	case 5 :
            	    // ANMLTree.g:563:4: ^( LessThanE r= expression )
            	    {
            	    match(input,LessThanE,FOLLOW_LessThanE_in_chain_stmt1768); if (state.failed) return c;

            	    match(input, Token.DOWN, null); if (state.failed) return c;
            	    pushFollow(FOLLOW_expression_in_chain_stmt1772);
            	    r=expression();

            	    state._fsp--;
            	    if (state.failed) return c;

            	    match(input, Token.UP, null); if (state.failed) return c;
            	    if ( state.backtracking==0 ) {

            	      			c.expressions.add(new OpBinary(TypeCode.Boolean,Op.lessThanE,l,r));
            	      		
            	    }

            	    }
            	    break;
            	case 6 :
            	    // ANMLTree.g:566:4: ^( GreaterThanE r= expression )
            	    {
            	    match(input,GreaterThanE,FOLLOW_GreaterThanE_in_chain_stmt1781); if (state.failed) return c;

            	    match(input, Token.DOWN, null); if (state.failed) return c;
            	    pushFollow(FOLLOW_expression_in_chain_stmt1785);
            	    r=expression();

            	    state._fsp--;
            	    if (state.failed) return c;

            	    match(input, Token.UP, null); if (state.failed) return c;
            	    if ( state.backtracking==0 ) {

            	      			c.expressions.add(new OpBinary(TypeCode.Boolean,Op.greaterThanE,l,r));
            	      		
            	    }

            	    }
            	    break;
            	case 7 :
            	    // ANMLTree.g:569:4: ^( Assign r= expression )
            	    {
            	    match(input,Assign,FOLLOW_Assign_in_chain_stmt1794); if (state.failed) return c;

            	    match(input, Token.DOWN, null); if (state.failed) return c;
            	    pushFollow(FOLLOW_expression_in_chain_stmt1798);
            	    r=expression();

            	    state._fsp--;
            	    if (state.failed) return c;

            	    match(input, Token.UP, null); if (state.failed) return c;
            	    if ( state.backtracking==0 ) {

            	      			if (l instanceof Constant) {
            	      				Constant lc = (Constant) l;
            	      				if (lc.name == IntervalImp.startName || lc.name == IntervalImp.endName || lc.name == IntervalImp.durationName) {
            	      					if (lc.init == null)
            	      						lc.init = r;
            	      					else
            	      					  	System.err.println("Can only set time parameters once.");
            	      					c.expressions.add(new Skip());
            	      				} else {
            	      					c.expressions.add(new Assign(l,r));
            	      					// might be nested within when statements and similar, so that one has to dynamically check whether multiple inits have happened					
            	      					if (lc.init != null)
            	      						System.err.println("Constant " + lc.name + " is defined twice?\n");
            	      				}
            	      			} else {
            	      				c.expressions.add(new Assign(l,r));
            	      			}
            	      		
            	    }

            	    }
            	    break;
            	case 8 :
            	    // ANMLTree.g:588:4: ^( Change r= expression )
            	    {
            	    match(input,Change,FOLLOW_Change_in_chain_stmt1807); if (state.failed) return c;

            	    match(input, Token.DOWN, null); if (state.failed) return c;
            	    pushFollow(FOLLOW_expression_in_chain_stmt1811);
            	    r=expression();

            	    state._fsp--;
            	    if (state.failed) return c;

            	    match(input, Token.UP, null); if (state.failed) return c;
            	    if ( state.backtracking==0 ) {

            	      			c.expressions.add(new Change(l,r));
            	      		
            	    }

            	    }
            	    break;
            	case 9 :
            	    // ANMLTree.g:591:4: ^( Lend r= expression )
            	    {
            	    match(input,Lend,FOLLOW_Lend_in_chain_stmt1820); if (state.failed) return c;

            	    match(input, Token.DOWN, null); if (state.failed) return c;
            	    pushFollow(FOLLOW_expression_in_chain_stmt1824);
            	    r=expression();

            	    state._fsp--;
            	    if (state.failed) return c;

            	    match(input, Token.UP, null); if (state.failed) return c;
            	    if ( state.backtracking==0 ) {

            	      			c.expressions.add(new Lend(l,r));
            	      		
            	    }

            	    }
            	    break;
            	case 10 :
            	    // ANMLTree.g:594:4: ^( Use r= expression )
            	    {
            	    match(input,Use,FOLLOW_Use_in_chain_stmt1833); if (state.failed) return c;

            	    match(input, Token.DOWN, null); if (state.failed) return c;
            	    pushFollow(FOLLOW_expression_in_chain_stmt1837);
            	    r=expression();

            	    state._fsp--;
            	    if (state.failed) return c;

            	    match(input, Token.UP, null); if (state.failed) return c;
            	    if ( state.backtracking==0 ) {

            	      			c.expressions.add(new Use(l,r));
            	      		
            	    }

            	    }
            	    break;
            	case 11 :
            	    // ANMLTree.g:597:4: ^( Produce r= expression )
            	    {
            	    match(input,Produce,FOLLOW_Produce_in_chain_stmt1846); if (state.failed) return c;

            	    match(input, Token.DOWN, null); if (state.failed) return c;
            	    pushFollow(FOLLOW_expression_in_chain_stmt1850);
            	    r=expression();

            	    state._fsp--;
            	    if (state.failed) return c;

            	    match(input, Token.UP, null); if (state.failed) return c;
            	    if ( state.backtracking==0 ) {

            	      			c.expressions.add(new Produce(l,r));
            	      		
            	    }

            	    }
            	    break;
            	case 12 :
            	    // ANMLTree.g:600:4: ^( Consume r= expression )
            	    {
            	    match(input,Consume,FOLLOW_Consume_in_chain_stmt1859); if (state.failed) return c;

            	    match(input, Token.DOWN, null); if (state.failed) return c;
            	    pushFollow(FOLLOW_expression_in_chain_stmt1863);
            	    r=expression();

            	    state._fsp--;
            	    if (state.failed) return c;

            	    match(input, Token.UP, null); if (state.failed) return c;
            	    if ( state.backtracking==0 ) {

            	      			c.expressions.add(new Consume(l,r));
            	      		
            	    }

            	    }
            	    break;
            	case 13 :
            	    // ANMLTree.g:603:4: ^( SetAssign set )
            	    {
            	    match(input,SetAssign,FOLLOW_SetAssign_in_chain_stmt1872); if (state.failed) return c;

            	    match(input, Token.DOWN, null); if (state.failed) return c;
            	    pushFollow(FOLLOW_set_in_chain_stmt1874);
            	    set();

            	    state._fsp--;
            	    if (state.failed) return c;

            	    match(input, Token.UP, null); if (state.failed) return c;
            	    if ( state.backtracking==0 ) {

            	      			c.expressions.add(new Undefine(l));
            	      		
            	    }

            	    }
            	    break;
            	case 14 :
            	    // ANMLTree.g:606:4: ^( Within set )
            	    {
            	    match(input,Within,FOLLOW_Within_in_chain_stmt1883); if (state.failed) return c;

            	    match(input, Token.DOWN, null); if (state.failed) return c;
            	    pushFollow(FOLLOW_set_in_chain_stmt1885);
            	    set();

            	    state._fsp--;
            	    if (state.failed) return c;

            	    match(input, Token.UP, null); if (state.failed) return c;
            	    if ( state.backtracking==0 ) {

            	      			c.expressions.add(new Skip());
            	      		
            	    }

            	    }
            	    break;
            	case 15 :
            	    // ANMLTree.g:609:4: Undefine
            	    {
            	    match(input,Undefine,FOLLOW_Undefine_in_chain_stmt1893); if (state.failed) return c;
            	    if ( state.backtracking==0 ) {

            	      			c.expressions.add(new Undefine(l));
            	      		
            	    }

            	    }
            	    break;
            	case 16 :
            	    // ANMLTree.g:612:4: Skip
            	    {
            	    match(input,Skip,FOLLOW_Skip_in_chain_stmt1900); if (state.failed) return c;
            	    if ( state.backtracking==0 ) {

            	      			c.expressions.add(new Skip());
            	      		
            	    }

            	    }
            	    break;

            	default :
            	    if ( cnt41 >= 1 ) break loop41;
            	    if (state.backtracking>0) {state.failed=true; return c;}
                        EarlyExitException eee =
                            new EarlyExitException(41, input);
                        throw eee;
                }
                cnt41++;
            } while (true);


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return c;
    }
    // $ANTLR end "chain_stmt"


    // $ANTLR start "float_expression"
    // ANMLTree.g:618:1: float_expression returns [Expression<SimpleFloat,?> e] : expression {...}?;
    public final Expression<SimpleFloat,?> float_expression() throws RecognitionException {
        Expression<SimpleFloat,?> e = null;

        Expression<?,?> expression45 = null;


        try {
            // ANMLTree.g:619:1: ( expression {...}?)
            // ANMLTree.g:620:2: expression {...}?
            {
            pushFollow(FOLLOW_expression_in_float_expression1920);
            expression45=expression();

            state._fsp--;
            if (state.failed) return e;
            if ( !((expression45.typeCode() == TypeCode.Float)) ) {
                if (state.backtracking>0) {state.failed=true; return e;}
                throw new FailedPredicateException(input, "float_expression", "$expression.e.typeCode() == TypeCode.Float");
            }
            if ( state.backtracking==0 ) {
               e = (Expression<SimpleFloat,?>) expression45; 
            }

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return e;
    }
    // $ANTLR end "float_expression"


    // $ANTLR start "boolean_expression"
    // ANMLTree.g:623:1: boolean_expression returns [Expression<SimpleBoolean,?> e] : expression {...}?;
    public final Expression<SimpleBoolean,?> boolean_expression() throws RecognitionException {
        Expression<SimpleBoolean,?> e = null;

        Expression<?,?> expression46 = null;


        try {
            // ANMLTree.g:624:1: ( expression {...}?)
            // ANMLTree.g:625:2: expression {...}?
            {
            pushFollow(FOLLOW_expression_in_boolean_expression1938);
            expression46=expression();

            state._fsp--;
            if (state.failed) return e;
            if ( !((expression46.typeCode() == TypeCode.Boolean)) ) {
                if (state.backtracking>0) {state.failed=true; return e;}
                throw new FailedPredicateException(input, "boolean_expression", "$expression.e.typeCode() == TypeCode.Boolean");
            }
            if ( state.backtracking==0 ) {
               e = (Expression<SimpleBoolean,?>) expression46; 
            }

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return e;
    }
    // $ANTLR end "boolean_expression"


    // $ANTLR start "interval"
    // ANMLTree.g:632:1: interval[IntervalImp i] : ( ^( DefiniteInterval b= bra ( ^( TDuration d= float_expression ) ^( TEnd e= float_expression ) k1= ket | ^( TStart s= float_expression ) ( ^( TDuration d= float_expression ) ( ^( TEnd e= float_expression ) k2= ket | k2= ket ) | ^( TEnd e= float_expression ) k2= ket ) ) ) | ^( DefinitePoint ^( TStart s= float_expression ) ) | ^( IndefiniteInterval b= bra ( ^( TDuration d= float_expression ) k1= ket | ^( TEnd e= float_expression ) k2= ket | ^( TStart s= float_expression ) k3= ket | k4= ket ) ) | IndefinitePoint );
    public final void interval(IntervalImp i) throws RecognitionException {
        Expression b = null;

        Expression<SimpleFloat,?> d = null;

        Expression<SimpleFloat,?> e = null;

        Expression k1 = null;

        Expression<SimpleFloat,?> s = null;

        Expression k2 = null;

        Expression k3 = null;

        Expression k4 = null;


        try {
            // ANMLTree.g:633:2: ( ^( DefiniteInterval b= bra ( ^( TDuration d= float_expression ) ^( TEnd e= float_expression ) k1= ket | ^( TStart s= float_expression ) ( ^( TDuration d= float_expression ) ( ^( TEnd e= float_expression ) k2= ket | k2= ket ) | ^( TEnd e= float_expression ) k2= ket ) ) ) | ^( DefinitePoint ^( TStart s= float_expression ) ) | ^( IndefiniteInterval b= bra ( ^( TDuration d= float_expression ) k1= ket | ^( TEnd e= float_expression ) k2= ket | ^( TStart s= float_expression ) k3= ket | k4= ket ) ) | IndefinitePoint )
            int alt46=4;
            switch ( input.LA(1) ) {
            case DefiniteInterval:
                {
                alt46=1;
                }
                break;
            case DefinitePoint:
                {
                alt46=2;
                }
                break;
            case IndefiniteInterval:
                {
                alt46=3;
                }
                break;
            case IndefinitePoint:
                {
                alt46=4;
                }
                break;
            default:
                if (state.backtracking>0) {state.failed=true; return ;}
                NoViableAltException nvae =
                    new NoViableAltException("", 46, 0, input);

                throw nvae;
            }

            switch (alt46) {
                case 1 :
                    // ANMLTree.g:633:4: ^( DefiniteInterval b= bra ( ^( TDuration d= float_expression ) ^( TEnd e= float_expression ) k1= ket | ^( TStart s= float_expression ) ( ^( TDuration d= float_expression ) ( ^( TEnd e= float_expression ) k2= ket | k2= ket ) | ^( TEnd e= float_expression ) k2= ket ) ) )
                    {
                    match(input,DefiniteInterval,FOLLOW_DefiniteInterval_in_interval1958); if (state.failed) return ;

                    match(input, Token.DOWN, null); if (state.failed) return ;
                    pushFollow(FOLLOW_bra_in_interval1962);
                    b=bra();

                    state._fsp--;
                    if (state.failed) return ;
                    // ANMLTree.g:634:3: ( ^( TDuration d= float_expression ) ^( TEnd e= float_expression ) k1= ket | ^( TStart s= float_expression ) ( ^( TDuration d= float_expression ) ( ^( TEnd e= float_expression ) k2= ket | k2= ket ) | ^( TEnd e= float_expression ) k2= ket ) )
                    int alt44=2;
                    int LA44_0 = input.LA(1);

                    if ( (LA44_0==TDuration) ) {
                        alt44=1;
                    }
                    else if ( (LA44_0==TStart) ) {
                        alt44=2;
                    }
                    else {
                        if (state.backtracking>0) {state.failed=true; return ;}
                        NoViableAltException nvae =
                            new NoViableAltException("", 44, 0, input);

                        throw nvae;
                    }
                    switch (alt44) {
                        case 1 :
                            // ANMLTree.g:634:5: ^( TDuration d= float_expression ) ^( TEnd e= float_expression ) k1= ket
                            {
                            match(input,TDuration,FOLLOW_TDuration_in_interval1970); if (state.failed) return ;

                            match(input, Token.DOWN, null); if (state.failed) return ;
                            pushFollow(FOLLOW_float_expression_in_interval1974);
                            d=float_expression();

                            state._fsp--;
                            if (state.failed) return ;

                            match(input, Token.UP, null); if (state.failed) return ;
                            match(input,TEnd,FOLLOW_TEnd_in_interval1978); if (state.failed) return ;

                            match(input, Token.DOWN, null); if (state.failed) return ;
                            pushFollow(FOLLOW_float_expression_in_interval1982);
                            e=float_expression();

                            state._fsp--;
                            if (state.failed) return ;

                            match(input, Token.UP, null); if (state.failed) return ;
                            pushFollow(FOLLOW_ket_in_interval1987);
                            k1=ket();

                            state._fsp--;
                            if (state.failed) return ;
                            if ( state.backtracking==0 ) {
                               
                              			i.setShape(b,k1);
                              			i.makeDuration(d); 
                              			i.makeEnd(e); 
                              			i.inferStart(); 
                              			
                            }

                            }
                            break;
                        case 2 :
                            // ANMLTree.g:640:5: ^( TStart s= float_expression ) ( ^( TDuration d= float_expression ) ( ^( TEnd e= float_expression ) k2= ket | k2= ket ) | ^( TEnd e= float_expression ) k2= ket )
                            {
                            match(input,TStart,FOLLOW_TStart_in_interval1997); if (state.failed) return ;

                            match(input, Token.DOWN, null); if (state.failed) return ;
                            pushFollow(FOLLOW_float_expression_in_interval2001);
                            s=float_expression();

                            state._fsp--;
                            if (state.failed) return ;

                            match(input, Token.UP, null); if (state.failed) return ;
                            // ANMLTree.g:641:7: ( ^( TDuration d= float_expression ) ( ^( TEnd e= float_expression ) k2= ket | k2= ket ) | ^( TEnd e= float_expression ) k2= ket )
                            int alt43=2;
                            int LA43_0 = input.LA(1);

                            if ( (LA43_0==TDuration) ) {
                                alt43=1;
                            }
                            else if ( (LA43_0==TEnd) ) {
                                alt43=2;
                            }
                            else {
                                if (state.backtracking>0) {state.failed=true; return ;}
                                NoViableAltException nvae =
                                    new NoViableAltException("", 43, 0, input);

                                throw nvae;
                            }
                            switch (alt43) {
                                case 1 :
                                    // ANMLTree.g:641:9: ^( TDuration d= float_expression ) ( ^( TEnd e= float_expression ) k2= ket | k2= ket )
                                    {
                                    match(input,TDuration,FOLLOW_TDuration_in_interval2013); if (state.failed) return ;

                                    match(input, Token.DOWN, null); if (state.failed) return ;
                                    pushFollow(FOLLOW_float_expression_in_interval2017);
                                    d=float_expression();

                                    state._fsp--;
                                    if (state.failed) return ;

                                    match(input, Token.UP, null); if (state.failed) return ;
                                    // ANMLTree.g:642:8: ( ^( TEnd e= float_expression ) k2= ket | k2= ket )
                                    int alt42=2;
                                    int LA42_0 = input.LA(1);

                                    if ( (LA42_0==TEnd) ) {
                                        alt42=1;
                                    }
                                    else if ( (LA42_0==TKet) ) {
                                        alt42=2;
                                    }
                                    else {
                                        if (state.backtracking>0) {state.failed=true; return ;}
                                        NoViableAltException nvae =
                                            new NoViableAltException("", 42, 0, input);

                                        throw nvae;
                                    }
                                    switch (alt42) {
                                        case 1 :
                                            // ANMLTree.g:642:10: ^( TEnd e= float_expression ) k2= ket
                                            {
                                            match(input,TEnd,FOLLOW_TEnd_in_interval2031); if (state.failed) return ;

                                            match(input, Token.DOWN, null); if (state.failed) return ;
                                            pushFollow(FOLLOW_float_expression_in_interval2035);
                                            e=float_expression();

                                            state._fsp--;
                                            if (state.failed) return ;

                                            match(input, Token.UP, null); if (state.failed) return ;
                                            pushFollow(FOLLOW_ket_in_interval2040);
                                            k2=ket();

                                            state._fsp--;
                                            if (state.failed) return ;
                                            if ( state.backtracking==0 ) {
                                               
                                              	    				i.setShape(b,k2);
                                              	    				i.makeStart(s);
                                              	    				i.makeDuration(d);
                                              	    				i.makeEnd(e);
                                              	    			
                                            }

                                            }
                                            break;
                                        case 2 :
                                            // ANMLTree.g:648:10: k2= ket
                                            {
                                            pushFollow(FOLLOW_ket_in_interval2055);
                                            k2=ket();

                                            state._fsp--;
                                            if (state.failed) return ;
                                            if ( state.backtracking==0 ) {

                                                  					i.setShape(b,k2);
                                                  					i.makeStart(s);
                                                  					i.makeDuration(d);
                                                  			    	i.inferEnd();
                                              	    			
                                            }

                                            }
                                            break;

                                    }


                                    }
                                    break;
                                case 2 :
                                    // ANMLTree.g:655:9: ^( TEnd e= float_expression ) k2= ket
                                    {
                                    match(input,TEnd,FOLLOW_TEnd_in_interval2077); if (state.failed) return ;

                                    match(input, Token.DOWN, null); if (state.failed) return ;
                                    pushFollow(FOLLOW_float_expression_in_interval2081);
                                    e=float_expression();

                                    state._fsp--;
                                    if (state.failed) return ;

                                    match(input, Token.UP, null); if (state.failed) return ;
                                    pushFollow(FOLLOW_ket_in_interval2086);
                                    k2=ket();

                                    state._fsp--;
                                    if (state.failed) return ;
                                    if ( state.backtracking==0 ) {

                                      				i.setShape(b,k2);
                                          			i.makeStart(s);
                                          			i.makeEnd(e); 
                                          			i.inferDuration();
                                      	    		
                                    }

                                    }
                                    break;

                            }


                            }
                            break;

                    }


                    match(input, Token.UP, null); if (state.failed) return ;

                    }
                    break;
                case 2 :
                    // ANMLTree.g:664:4: ^( DefinitePoint ^( TStart s= float_expression ) )
                    {
                    match(input,DefinitePoint,FOLLOW_DefinitePoint_in_interval2113); if (state.failed) return ;

                    match(input, Token.DOWN, null); if (state.failed) return ;
                    match(input,TStart,FOLLOW_TStart_in_interval2116); if (state.failed) return ;

                    match(input, Token.DOWN, null); if (state.failed) return ;
                    pushFollow(FOLLOW_float_expression_in_interval2120);
                    s=float_expression();

                    state._fsp--;
                    if (state.failed) return ;

                    match(input, Token.UP, null); if (state.failed) return ;
                    if ( state.backtracking==0 ) {

                      			i.setShape(0,0);
                      			i.makeStart(s);
                      			i.makeEnd(s);
                      			i.inferDuration(); 
                      			// surely the following should work?
                      			//i.duration = IntervalImp.constantDurationZero;
                      		
                    }

                    match(input, Token.UP, null); if (state.failed) return ;

                    }
                    break;
                case 3 :
                    // ANMLTree.g:673:4: ^( IndefiniteInterval b= bra ( ^( TDuration d= float_expression ) k1= ket | ^( TEnd e= float_expression ) k2= ket | ^( TStart s= float_expression ) k3= ket | k4= ket ) )
                    {
                    match(input,IndefiniteInterval,FOLLOW_IndefiniteInterval_in_interval2135); if (state.failed) return ;

                    match(input, Token.DOWN, null); if (state.failed) return ;
                    pushFollow(FOLLOW_bra_in_interval2139);
                    b=bra();

                    state._fsp--;
                    if (state.failed) return ;
                    // ANMLTree.g:674:3: ( ^( TDuration d= float_expression ) k1= ket | ^( TEnd e= float_expression ) k2= ket | ^( TStart s= float_expression ) k3= ket | k4= ket )
                    int alt45=4;
                    switch ( input.LA(1) ) {
                    case TDuration:
                        {
                        alt45=1;
                        }
                        break;
                    case TEnd:
                        {
                        alt45=2;
                        }
                        break;
                    case TStart:
                        {
                        alt45=3;
                        }
                        break;
                    case TKet:
                        {
                        alt45=4;
                        }
                        break;
                    default:
                        if (state.backtracking>0) {state.failed=true; return ;}
                        NoViableAltException nvae =
                            new NoViableAltException("", 45, 0, input);

                        throw nvae;
                    }

                    switch (alt45) {
                        case 1 :
                            // ANMLTree.g:674:5: ^( TDuration d= float_expression ) k1= ket
                            {
                            match(input,TDuration,FOLLOW_TDuration_in_interval2147); if (state.failed) return ;

                            match(input, Token.DOWN, null); if (state.failed) return ;
                            pushFollow(FOLLOW_float_expression_in_interval2151);
                            d=float_expression();

                            state._fsp--;
                            if (state.failed) return ;

                            match(input, Token.UP, null); if (state.failed) return ;
                            pushFollow(FOLLOW_ket_in_interval2156);
                            k1=ket();

                            state._fsp--;
                            if (state.failed) return ;
                            if ( state.backtracking==0 ) {
                               
                              			i.setShape(b,k1); 
                              			i.makeDuration(d); 
                              			i.start = new Constant<SimpleFloat>(IntervalImp.startName,Unit.floatType);
                              			i.end = new Constant<SimpleFloat>(IntervalImp.endName,Unit.floatType);
                              			
                            }

                            }
                            break;
                        case 2 :
                            // ANMLTree.g:680:5: ^( TEnd e= float_expression ) k2= ket
                            {
                            match(input,TEnd,FOLLOW_TEnd_in_interval2165); if (state.failed) return ;

                            match(input, Token.DOWN, null); if (state.failed) return ;
                            pushFollow(FOLLOW_float_expression_in_interval2169);
                            e=float_expression();

                            state._fsp--;
                            if (state.failed) return ;

                            match(input, Token.UP, null); if (state.failed) return ;
                            pushFollow(FOLLOW_ket_in_interval2174);
                            k2=ket();

                            state._fsp--;
                            if (state.failed) return ;
                            if ( state.backtracking==0 ) {
                               
                              			i.setShape(b,k2); 
                              			i.makeEnd(e); 
                              			i.start = new Constant<SimpleFloat>(IntervalImp.startName,Unit.floatType);
                              			i.duration = new Constant<SimpleFloat>(IntervalImp.durationName,Unit.floatType);
                              			
                            }

                            }
                            break;
                        case 3 :
                            // ANMLTree.g:686:5: ^( TStart s= float_expression ) k3= ket
                            {
                            match(input,TStart,FOLLOW_TStart_in_interval2183); if (state.failed) return ;

                            match(input, Token.DOWN, null); if (state.failed) return ;
                            pushFollow(FOLLOW_float_expression_in_interval2187);
                            s=float_expression();

                            state._fsp--;
                            if (state.failed) return ;

                            match(input, Token.UP, null); if (state.failed) return ;
                            pushFollow(FOLLOW_ket_in_interval2192);
                            k3=ket();

                            state._fsp--;
                            if (state.failed) return ;
                            if ( state.backtracking==0 ) {
                               
                              			i.setShape(b,k3); 
                              			i.makeStart(s); 
                              			i.duration = new Constant<SimpleFloat>(IntervalImp.durationName,Unit.floatType);
                              			i.end = new Constant<SimpleFloat>(IntervalImp.endName,Unit.floatType);
                              			
                            }

                            }
                            break;
                        case 4 :
                            // ANMLTree.g:692:5: k4= ket
                            {
                            pushFollow(FOLLOW_ket_in_interval2202);
                            k4=ket();

                            state._fsp--;
                            if (state.failed) return ;
                            if ( state.backtracking==0 ) {
                               
                              			i.setShape(b,k4); 
                              			i.start = new Constant<SimpleFloat>(IntervalImp.startName,Unit.floatType);
                              			i.duration = new Constant<SimpleFloat>(IntervalImp.durationName,Unit.floatType);
                              			i.end = new Constant<SimpleFloat>(IntervalImp.endName,Unit.floatType);
                              			
                            }

                            }
                            break;

                    }


                    match(input, Token.UP, null); if (state.failed) return ;

                    }
                    break;
                case 4 :
                    // ANMLTree.g:700:4: IndefinitePoint
                    {
                    match(input,IndefinitePoint,FOLLOW_IndefinitePoint_in_interval2218); if (state.failed) return ;
                    if ( state.backtracking==0 ) {
                       
                      			i.setShape(0,0); 
                      			i.duration = IntervalImp.constantDurationZero;
                      			i.start = i.end = new Constant<SimpleFloat>(IntervalImp.startName,Unit.floatType);
                      		
                    }

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "interval"


    // $ANTLR start "bra"
    // ANMLTree.g:707:1: bra returns [Expression b] : ^( TBra ( At | After | Before | expression ) ) ;
    public final Expression bra() throws RecognitionException {
        Expression b = null;

        Expression<?,?> expression47 = null;


        try {
            // ANMLTree.g:708:2: ( ^( TBra ( At | After | Before | expression ) ) )
            // ANMLTree.g:708:4: ^( TBra ( At | After | Before | expression ) )
            {
            match(input,TBra,FOLLOW_TBra_in_bra2236); if (state.failed) return b;

            match(input, Token.DOWN, null); if (state.failed) return b;
            // ANMLTree.g:709:3: ( At | After | Before | expression )
            int alt47=4;
            switch ( input.LA(1) ) {
            case At:
                {
                alt47=1;
                }
                break;
            case After:
                {
                alt47=2;
                }
                break;
            case Before:
                {
                alt47=3;
                }
                break;
            case LabelRef:
            case Ref:
            case Bind:
            case Access:
            case Label:
            case Bra:
            case Ket:
            case TimedExpr:
            case ContainsSomeExpr:
            case ContainsAllExpr:
            case ExistsExpr:
            case ID:
            case LessThan:
            case Assign:
            case Undefine:
            case NotLog:
            case NotBit:
            case EqualLog:
            case Equal:
            case Duration:
            case Change:
            case Produce:
            case Consume:
            case Lend:
            case Use:
            case Within:
            case SetAssign:
            case Skip:
            case Delta:
            case Implies:
            case XorLog:
            case OrLog:
            case AndLog:
            case XorBit:
            case Plus:
            case Minus:
            case OrBit:
            case Times:
            case Divide:
            case AndBit:
            case Unordered:
            case Ordered:
            case Start:
            case End:
            case INT:
            case FLOAT:
            case STRING:
            case True:
            case False:
            case Infinity:
            case NotEqual:
            case GreaterThan:
            case LessThanE:
            case GreaterThanE:
            case ForallExpr:
                {
                alt47=4;
                }
                break;
            default:
                if (state.backtracking>0) {state.failed=true; return b;}
                NoViableAltException nvae =
                    new NoViableAltException("", 47, 0, input);

                throw nvae;
            }

            switch (alt47) {
                case 1 :
                    // ANMLTree.g:709:5: At
                    {
                    match(input,At,FOLLOW_At_in_bra2243); if (state.failed) return b;
                    if ( state.backtracking==0 ) {
                      b=IntervalImp.makeBra(Time.At);
                    }

                    }
                    break;
                case 2 :
                    // ANMLTree.g:710:5: After
                    {
                    match(input,After,FOLLOW_After_in_bra2252); if (state.failed) return b;
                    if ( state.backtracking==0 ) {
                      b=IntervalImp.makeBra(Time.After);
                    }

                    }
                    break;
                case 3 :
                    // ANMLTree.g:711:5: Before
                    {
                    match(input,Before,FOLLOW_Before_in_bra2261); if (state.failed) return b;
                    if ( state.backtracking==0 ) {
                      b=IntervalImp.makeBra(Time.Before);
                    }

                    }
                    break;
                case 4 :
                    // ANMLTree.g:712:5: expression
                    {
                    pushFollow(FOLLOW_expression_in_bra2269);
                    expression47=expression();

                    state._fsp--;
                    if (state.failed) return b;
                    if ( state.backtracking==0 ) {
                      b = expression47;
                    }

                    }
                    break;

            }


            match(input, Token.UP, null); if (state.failed) return b;

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return b;
    }
    // $ANTLR end "bra"


    // $ANTLR start "ket"
    // ANMLTree.g:716:1: ket returns [Expression k] : ^( TKet ( At | Before | After | expression ) ) ;
    public final Expression ket() throws RecognitionException {
        Expression k = null;

        Expression<?,?> expression48 = null;


        try {
            // ANMLTree.g:717:2: ( ^( TKet ( At | Before | After | expression ) ) )
            // ANMLTree.g:717:4: ^( TKet ( At | Before | After | expression ) )
            {
            match(input,TKet,FOLLOW_TKet_in_ket2295); if (state.failed) return k;

            match(input, Token.DOWN, null); if (state.failed) return k;
            // ANMLTree.g:718:3: ( At | Before | After | expression )
            int alt48=4;
            switch ( input.LA(1) ) {
            case At:
                {
                alt48=1;
                }
                break;
            case Before:
                {
                alt48=2;
                }
                break;
            case After:
                {
                alt48=3;
                }
                break;
            case LabelRef:
            case Ref:
            case Bind:
            case Access:
            case Label:
            case Bra:
            case Ket:
            case TimedExpr:
            case ContainsSomeExpr:
            case ContainsAllExpr:
            case ExistsExpr:
            case ID:
            case LessThan:
            case Assign:
            case Undefine:
            case NotLog:
            case NotBit:
            case EqualLog:
            case Equal:
            case Duration:
            case Change:
            case Produce:
            case Consume:
            case Lend:
            case Use:
            case Within:
            case SetAssign:
            case Skip:
            case Delta:
            case Implies:
            case XorLog:
            case OrLog:
            case AndLog:
            case XorBit:
            case Plus:
            case Minus:
            case OrBit:
            case Times:
            case Divide:
            case AndBit:
            case Unordered:
            case Ordered:
            case Start:
            case End:
            case INT:
            case FLOAT:
            case STRING:
            case True:
            case False:
            case Infinity:
            case NotEqual:
            case GreaterThan:
            case LessThanE:
            case GreaterThanE:
            case ForallExpr:
                {
                alt48=4;
                }
                break;
            default:
                if (state.backtracking>0) {state.failed=true; return k;}
                NoViableAltException nvae =
                    new NoViableAltException("", 48, 0, input);

                throw nvae;
            }

            switch (alt48) {
                case 1 :
                    // ANMLTree.g:718:5: At
                    {
                    match(input,At,FOLLOW_At_in_ket2302); if (state.failed) return k;
                    if ( state.backtracking==0 ) {
                      k=IntervalImp.makeKet(Time.At);
                    }

                    }
                    break;
                case 2 :
                    // ANMLTree.g:719:5: Before
                    {
                    match(input,Before,FOLLOW_Before_in_ket2311); if (state.failed) return k;
                    if ( state.backtracking==0 ) {
                      k=IntervalImp.makeKet(Time.Before);
                    }

                    }
                    break;
                case 3 :
                    // ANMLTree.g:720:5: After
                    {
                    match(input,After,FOLLOW_After_in_ket2320); if (state.failed) return k;
                    if ( state.backtracking==0 ) {
                      k=IntervalImp.makeKet(Time.After);
                    }

                    }
                    break;
                case 4 :
                    // ANMLTree.g:721:5: expression
                    {
                    pushFollow(FOLLOW_expression_in_ket2328);
                    expression48=expression();

                    state._fsp--;
                    if (state.failed) return k;
                    if ( state.backtracking==0 ) {
                      k=expression48;
                    }

                    }
                    break;

            }


            match(input, Token.UP, null); if (state.failed) return k;

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return k;
    }
    // $ANTLR end "ket"


    // $ANTLR start "timed_expression"
    // ANMLTree.g:728:1: timed_expression[Interval i] returns [Expression<?,?> e] : expression ;
    public final Expression<?,?> timed_expression(Interval i) throws RecognitionException {
        I_stack.push(new I_scope());

        Expression<?,?> e = null;

        Expression<?,?> expression49 = null;


        ((I_scope)I_stack.peek()).i = i;
        try {
            // ANMLTree.g:731:2: ( expression )
            // ANMLTree.g:731:4: expression
            {
            pushFollow(FOLLOW_expression_in_timed_expression2366);
            expression49=expression();

            state._fsp--;
            if (state.failed) return e;
            if ( state.backtracking==0 ) {
              e = expression49;
            }

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
            I_stack.pop();

        }
        return e;
    }
    // $ANTLR end "timed_expression"


    // $ANTLR start "expression"
    // ANMLTree.g:734:1: expression returns [Expression<?,?> e] : ( ^( Label id f= expression ) | ^( ( Equal | EqualLog ) l= expression r= expression ) | ^( NotEqual l= expression r= expression ) | ^( LessThan l= expression r= expression ) | ^( GreaterThan l= expression r= expression ) | ^( LessThanE l= expression r= expression ) | ^( GreaterThanE l= expression r= expression ) | ^( Assign l= expression r= expression ) | ^( Undefine l= expression ) | Skip | ^( Change l= expression r= expression ) | ^( Lend l= expression r= expression ) | ^( Use l= expression r= expression ) | ^( Produce l= expression r= expression ) | ^( Consume l= expression r= expression ) | ^( Within expression set ) | ^( SetAssign expression set ) | ^( Implies l= expression r= expression ) | ^( ( XorLog | XorBit ) l= expression r= expression ) | ^( ( AndLog | AndBit ) l= expression r= expression ) | ^( ( OrLog | OrBit ) l= expression r= expression ) | ^( Plus l= expression r= expression ) | ^( Minus l= expression r= expression ) | ^( Times l= expression r= expression ) | ^( Divide l= expression r= expression ) | ^( ForallExpr ^( Parameters scope_arg_decl_list[forall] ) l= expression ) | ^( ExistsExpr ^( Parameters scope_arg_decl_list[exists] ) l= expression ) | ^( ContainsSomeExpr interval[te] tl= timed_expression[te] ) | ^( ContainsAllExpr b= boolean_expression ) | ^( TimedExpr interval[te] tl= timed_expression[te] ) | ^( Unordered (b= boolean_expression )* ) | ^( Ordered (b= boolean_expression )* ) | ^( ( NotLog | NotBit ) ( ( ref )=> ref | l= expression ) ) | ref | ^( Delta ref ) | literal | time_primitive );
    public final Expression<?,?> expression() throws RecognitionException {
        Expression<?,?> e = null;

        ANMLToken Label50=null;
        ANMLToken ForallExpr52=null;
        ANMLToken ExistsExpr53=null;
        Expression<?,?> f = null;

        Expression<?,?> l = null;

        Expression<?,?> r = null;

        Expression<?,?> tl = null;

        Expression<SimpleBoolean,?> b = null;

        SimpleString id51 = null;

        OpUnary ref54 = null;

        OpUnary ref55 = null;

        Expression literal56 = null;

        Expression time_primitive57 = null;



        	LabeledExpression label;
        	ForAll forall=null;
        	Exists exists=null;
        	Ordered ordered=null;
        	Unordered unordered=null;
        	TimedExpression te=null;

        try {
            // ANMLTree.g:743:2: ( ^( Label id f= expression ) | ^( ( Equal | EqualLog ) l= expression r= expression ) | ^( NotEqual l= expression r= expression ) | ^( LessThan l= expression r= expression ) | ^( GreaterThan l= expression r= expression ) | ^( LessThanE l= expression r= expression ) | ^( GreaterThanE l= expression r= expression ) | ^( Assign l= expression r= expression ) | ^( Undefine l= expression ) | Skip | ^( Change l= expression r= expression ) | ^( Lend l= expression r= expression ) | ^( Use l= expression r= expression ) | ^( Produce l= expression r= expression ) | ^( Consume l= expression r= expression ) | ^( Within expression set ) | ^( SetAssign expression set ) | ^( Implies l= expression r= expression ) | ^( ( XorLog | XorBit ) l= expression r= expression ) | ^( ( AndLog | AndBit ) l= expression r= expression ) | ^( ( OrLog | OrBit ) l= expression r= expression ) | ^( Plus l= expression r= expression ) | ^( Minus l= expression r= expression ) | ^( Times l= expression r= expression ) | ^( Divide l= expression r= expression ) | ^( ForallExpr ^( Parameters scope_arg_decl_list[forall] ) l= expression ) | ^( ExistsExpr ^( Parameters scope_arg_decl_list[exists] ) l= expression ) | ^( ContainsSomeExpr interval[te] tl= timed_expression[te] ) | ^( ContainsAllExpr b= boolean_expression ) | ^( TimedExpr interval[te] tl= timed_expression[te] ) | ^( Unordered (b= boolean_expression )* ) | ^( Ordered (b= boolean_expression )* ) | ^( ( NotLog | NotBit ) ( ( ref )=> ref | l= expression ) ) | ref | ^( Delta ref ) | literal | time_primitive )
            int alt52=37;
            switch ( input.LA(1) ) {
            case Label:
                {
                alt52=1;
                }
                break;
            case EqualLog:
            case Equal:
                {
                alt52=2;
                }
                break;
            case NotEqual:
                {
                alt52=3;
                }
                break;
            case LessThan:
                {
                alt52=4;
                }
                break;
            case GreaterThan:
                {
                alt52=5;
                }
                break;
            case LessThanE:
                {
                alt52=6;
                }
                break;
            case GreaterThanE:
                {
                alt52=7;
                }
                break;
            case Assign:
                {
                alt52=8;
                }
                break;
            case Undefine:
                {
                alt52=9;
                }
                break;
            case Skip:
                {
                alt52=10;
                }
                break;
            case Change:
                {
                alt52=11;
                }
                break;
            case Lend:
                {
                alt52=12;
                }
                break;
            case Use:
                {
                alt52=13;
                }
                break;
            case Produce:
                {
                alt52=14;
                }
                break;
            case Consume:
                {
                alt52=15;
                }
                break;
            case Within:
                {
                alt52=16;
                }
                break;
            case SetAssign:
                {
                alt52=17;
                }
                break;
            case Implies:
                {
                alt52=18;
                }
                break;
            case XorLog:
            case XorBit:
                {
                alt52=19;
                }
                break;
            case AndLog:
            case AndBit:
                {
                alt52=20;
                }
                break;
            case OrLog:
            case OrBit:
                {
                alt52=21;
                }
                break;
            case Plus:
                {
                alt52=22;
                }
                break;
            case Minus:
                {
                alt52=23;
                }
                break;
            case Times:
                {
                alt52=24;
                }
                break;
            case Divide:
                {
                alt52=25;
                }
                break;
            case ForallExpr:
                {
                alt52=26;
                }
                break;
            case ExistsExpr:
                {
                alt52=27;
                }
                break;
            case ContainsSomeExpr:
                {
                alt52=28;
                }
                break;
            case ContainsAllExpr:
                {
                alt52=29;
                }
                break;
            case TimedExpr:
                {
                alt52=30;
                }
                break;
            case Unordered:
                {
                alt52=31;
                }
                break;
            case Ordered:
                {
                alt52=32;
                }
                break;
            case NotLog:
            case NotBit:
                {
                alt52=33;
                }
                break;
            case Ref:
            case Bind:
            case Access:
                {
                alt52=34;
                }
                break;
            case Delta:
                {
                alt52=35;
                }
                break;
            case ID:
            case INT:
            case FLOAT:
            case STRING:
            case True:
            case False:
            case Infinity:
                {
                alt52=36;
                }
                break;
            case LabelRef:
            case Bra:
            case Ket:
            case Duration:
            case Start:
            case End:
                {
                alt52=37;
                }
                break;
            default:
                if (state.backtracking>0) {state.failed=true; return e;}
                NoViableAltException nvae =
                    new NoViableAltException("", 52, 0, input);

                throw nvae;
            }

            switch (alt52) {
                case 1 :
                    // ANMLTree.g:743:4: ^( Label id f= expression )
                    {
                    Label50=(ANMLToken)match(input,Label,FOLLOW_Label_in_expression2388); if (state.failed) return e;

                    match(input, Token.DOWN, null); if (state.failed) return e;
                    pushFollow(FOLLOW_id_in_expression2390);
                    id51=id();

                    state._fsp--;
                    if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2394);
                    f=expression();

                    state._fsp--;
                    if (state.failed) return e;

                    match(input, Token.UP, null); if (state.failed) return e;
                    if ( state.backtracking==0 ) {

                      		if (f == null || f.typeCode() != TypeCode.Boolean) {
                      			System.err.println("Error (line " + Label50.getLine() + "): Cannot label non-boolean expressions. [label: " + id51 + "]");
                      			// suppress undefined errors later.
                      			e = label = new LabeledExpression(id51,ANMLBoolean.False);
                      			((A_scope)A_stack.peek()).d.labels.put(label);
                      		} else {
                      			e = label = new LabeledExpression(id51,(Expression<SimpleBoolean,?>)f);
                      			((A_scope)A_stack.peek()).d.labels.put(label);
                      		}
                      	
                    }

                    }
                    break;
                case 2 :
                    // ANMLTree.g:754:4: ^( ( Equal | EqualLog ) l= expression r= expression )
                    {
                    if ( (input.LA(1)>=EqualLog && input.LA(1)<=Equal) ) {
                        input.consume();
                        state.errorRecovery=false;state.failed=false;
                    }
                    else {
                        if (state.backtracking>0) {state.failed=true; return e;}
                        MismatchedSetException mse = new MismatchedSetException(null,input);
                        throw mse;
                    }


                    match(input, Token.DOWN, null); if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2411);
                    l=expression();

                    state._fsp--;
                    if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2415);
                    r=expression();

                    state._fsp--;
                    if (state.failed) return e;

                    match(input, Token.UP, null); if (state.failed) return e;
                    if ( state.backtracking==0 ) {

                      			e = new OpBinary(TypeCode.Boolean,Op.equal,l,r);
                      		
                    }

                    }
                    break;
                case 3 :
                    // ANMLTree.g:757:4: ^( NotEqual l= expression r= expression )
                    {
                    match(input,NotEqual,FOLLOW_NotEqual_in_expression2424); if (state.failed) return e;

                    match(input, Token.DOWN, null); if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2428);
                    l=expression();

                    state._fsp--;
                    if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2432);
                    r=expression();

                    state._fsp--;
                    if (state.failed) return e;

                    match(input, Token.UP, null); if (state.failed) return e;
                    if ( state.backtracking==0 ) {

                      			e = new OpBinary(TypeCode.Boolean,Op.notEqual,l,r);
                      		
                    }

                    }
                    break;
                case 4 :
                    // ANMLTree.g:760:4: ^( LessThan l= expression r= expression )
                    {
                    match(input,LessThan,FOLLOW_LessThan_in_expression2441); if (state.failed) return e;

                    match(input, Token.DOWN, null); if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2445);
                    l=expression();

                    state._fsp--;
                    if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2449);
                    r=expression();

                    state._fsp--;
                    if (state.failed) return e;

                    match(input, Token.UP, null); if (state.failed) return e;
                    if ( state.backtracking==0 ) {

                      			e = new OpBinary(TypeCode.Boolean,Op.lessThan,l,r);
                      		
                    }

                    }
                    break;
                case 5 :
                    // ANMLTree.g:763:4: ^( GreaterThan l= expression r= expression )
                    {
                    match(input,GreaterThan,FOLLOW_GreaterThan_in_expression2458); if (state.failed) return e;

                    match(input, Token.DOWN, null); if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2462);
                    l=expression();

                    state._fsp--;
                    if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2466);
                    r=expression();

                    state._fsp--;
                    if (state.failed) return e;

                    match(input, Token.UP, null); if (state.failed) return e;
                    if ( state.backtracking==0 ) {

                      			e = new OpBinary(TypeCode.Boolean,Op.greaterThan,l,r);
                      		
                    }

                    }
                    break;
                case 6 :
                    // ANMLTree.g:766:4: ^( LessThanE l= expression r= expression )
                    {
                    match(input,LessThanE,FOLLOW_LessThanE_in_expression2475); if (state.failed) return e;

                    match(input, Token.DOWN, null); if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2479);
                    l=expression();

                    state._fsp--;
                    if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2483);
                    r=expression();

                    state._fsp--;
                    if (state.failed) return e;

                    match(input, Token.UP, null); if (state.failed) return e;
                    if ( state.backtracking==0 ) {

                      			e = new OpBinary(TypeCode.Boolean,Op.lessThanE,l,r);
                      		
                    }

                    }
                    break;
                case 7 :
                    // ANMLTree.g:769:4: ^( GreaterThanE l= expression r= expression )
                    {
                    match(input,GreaterThanE,FOLLOW_GreaterThanE_in_expression2492); if (state.failed) return e;

                    match(input, Token.DOWN, null); if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2496);
                    l=expression();

                    state._fsp--;
                    if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2500);
                    r=expression();

                    state._fsp--;
                    if (state.failed) return e;

                    match(input, Token.UP, null); if (state.failed) return e;
                    if ( state.backtracking==0 ) {

                      			e = new OpBinary(TypeCode.Boolean,Op.greaterThanE,l,r);
                      		
                    }

                    }
                    break;
                case 8 :
                    // ANMLTree.g:772:4: ^( Assign l= expression r= expression )
                    {
                    match(input,Assign,FOLLOW_Assign_in_expression2509); if (state.failed) return e;

                    match(input, Token.DOWN, null); if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2513);
                    l=expression();

                    state._fsp--;
                    if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2517);
                    r=expression();

                    state._fsp--;
                    if (state.failed) return e;

                    match(input, Token.UP, null); if (state.failed) return e;
                    if ( state.backtracking==0 ) {

                      			if (l instanceof Constant) {
                      				Constant c = (Constant) l;
                      				if (c.name == IntervalImp.startName || c.name == IntervalImp.endName || c.name == IntervalImp.durationName) {
                      					if (c.init == null)
                      						c.init = r;
                      					else
                      					  	System.err.println("Can only set time parameters once.");
                      					e = new Skip(); // shouldn't be needed...
                      				} else {
                      					// might be nested within when statements and similar, so that one has to dynamically check whether multiple inits have happened					
                      					e = new Assign(l,r);
                      					if (c.init != null)
                      						System.err.println("Constant " + c.name + " is defined twice?\n");
                      				}
                      			} else {
                      				e = new Assign(l,r);
                      			}
                      		
                    }

                    }
                    break;
                case 9 :
                    // ANMLTree.g:791:4: ^( Undefine l= expression )
                    {
                    match(input,Undefine,FOLLOW_Undefine_in_expression2526); if (state.failed) return e;

                    match(input, Token.DOWN, null); if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2530);
                    l=expression();

                    state._fsp--;
                    if (state.failed) return e;

                    match(input, Token.UP, null); if (state.failed) return e;
                    if ( state.backtracking==0 ) {

                      			e = new Undefine(l);
                      		
                    }

                    }
                    break;
                case 10 :
                    // ANMLTree.g:794:4: Skip
                    {
                    match(input,Skip,FOLLOW_Skip_in_expression2538); if (state.failed) return e;
                    if ( state.backtracking==0 ) {

                      			e = new Skip();
                      		
                    }

                    }
                    break;
                case 11 :
                    // ANMLTree.g:797:4: ^( Change l= expression r= expression )
                    {
                    match(input,Change,FOLLOW_Change_in_expression2546); if (state.failed) return e;

                    match(input, Token.DOWN, null); if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2550);
                    l=expression();

                    state._fsp--;
                    if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2554);
                    r=expression();

                    state._fsp--;
                    if (state.failed) return e;

                    match(input, Token.UP, null); if (state.failed) return e;
                    if ( state.backtracking==0 ) {

                      			e = new Change(l,r);
                      		
                    }

                    }
                    break;
                case 12 :
                    // ANMLTree.g:800:4: ^( Lend l= expression r= expression )
                    {
                    match(input,Lend,FOLLOW_Lend_in_expression2563); if (state.failed) return e;

                    match(input, Token.DOWN, null); if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2567);
                    l=expression();

                    state._fsp--;
                    if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2571);
                    r=expression();

                    state._fsp--;
                    if (state.failed) return e;

                    match(input, Token.UP, null); if (state.failed) return e;
                    if ( state.backtracking==0 ) {

                      			e = new Lend(l,r);
                      		
                    }

                    }
                    break;
                case 13 :
                    // ANMLTree.g:803:4: ^( Use l= expression r= expression )
                    {
                    match(input,Use,FOLLOW_Use_in_expression2580); if (state.failed) return e;

                    match(input, Token.DOWN, null); if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2584);
                    l=expression();

                    state._fsp--;
                    if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2588);
                    r=expression();

                    state._fsp--;
                    if (state.failed) return e;

                    match(input, Token.UP, null); if (state.failed) return e;
                    if ( state.backtracking==0 ) {

                      			e = new Use(l,r);
                      		
                    }

                    }
                    break;
                case 14 :
                    // ANMLTree.g:806:4: ^( Produce l= expression r= expression )
                    {
                    match(input,Produce,FOLLOW_Produce_in_expression2597); if (state.failed) return e;

                    match(input, Token.DOWN, null); if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2601);
                    l=expression();

                    state._fsp--;
                    if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2605);
                    r=expression();

                    state._fsp--;
                    if (state.failed) return e;

                    match(input, Token.UP, null); if (state.failed) return e;
                    if ( state.backtracking==0 ) {

                      			e = new Produce(l,r);
                      		
                    }

                    }
                    break;
                case 15 :
                    // ANMLTree.g:809:4: ^( Consume l= expression r= expression )
                    {
                    match(input,Consume,FOLLOW_Consume_in_expression2614); if (state.failed) return e;

                    match(input, Token.DOWN, null); if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2618);
                    l=expression();

                    state._fsp--;
                    if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2622);
                    r=expression();

                    state._fsp--;
                    if (state.failed) return e;

                    match(input, Token.UP, null); if (state.failed) return e;
                    if ( state.backtracking==0 ) {

                      			e = new Consume(l,r);
                      		
                    }

                    }
                    break;
                case 16 :
                    // ANMLTree.g:812:4: ^( Within expression set )
                    {
                    match(input,Within,FOLLOW_Within_in_expression2631); if (state.failed) return e;

                    match(input, Token.DOWN, null); if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2633);
                    expression();

                    state._fsp--;
                    if (state.failed) return e;
                    pushFollow(FOLLOW_set_in_expression2635);
                    set();

                    state._fsp--;
                    if (state.failed) return e;

                    match(input, Token.UP, null); if (state.failed) return e;
                    if ( state.backtracking==0 ) {

                      		
                    }

                    }
                    break;
                case 17 :
                    // ANMLTree.g:814:4: ^( SetAssign expression set )
                    {
                    match(input,SetAssign,FOLLOW_SetAssign_in_expression2644); if (state.failed) return e;

                    match(input, Token.DOWN, null); if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2646);
                    expression();

                    state._fsp--;
                    if (state.failed) return e;
                    pushFollow(FOLLOW_set_in_expression2648);
                    set();

                    state._fsp--;
                    if (state.failed) return e;

                    match(input, Token.UP, null); if (state.failed) return e;
                    if ( state.backtracking==0 ) {

                      		
                    }

                    }
                    break;
                case 18 :
                    // ANMLTree.g:816:4: ^( Implies l= expression r= expression )
                    {
                    match(input,Implies,FOLLOW_Implies_in_expression2657); if (state.failed) return e;

                    match(input, Token.DOWN, null); if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2661);
                    l=expression();

                    state._fsp--;
                    if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2665);
                    r=expression();

                    state._fsp--;
                    if (state.failed) return e;

                    match(input, Token.UP, null); if (state.failed) return e;
                    if ( state.backtracking==0 ) {

                      			e = new OpBinary(TypeCode.Boolean,Op.implies,l,r);
                      		
                    }

                    }
                    break;
                case 19 :
                    // ANMLTree.g:819:4: ^( ( XorLog | XorBit ) l= expression r= expression )
                    {
                    if ( input.LA(1)==XorLog||input.LA(1)==XorBit ) {
                        input.consume();
                        state.errorRecovery=false;state.failed=false;
                    }
                    else {
                        if (state.backtracking>0) {state.failed=true; return e;}
                        MismatchedSetException mse = new MismatchedSetException(null,input);
                        throw mse;
                    }


                    match(input, Token.DOWN, null); if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2682);
                    l=expression();

                    state._fsp--;
                    if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2686);
                    r=expression();

                    state._fsp--;
                    if (state.failed) return e;

                    match(input, Token.UP, null); if (state.failed) return e;
                    if ( state.backtracking==0 ) {

                      			e = new OpBinary(TypeCode.Boolean,Op.xor,l,r);
                      		
                    }

                    }
                    break;
                case 20 :
                    // ANMLTree.g:822:4: ^( ( AndLog | AndBit ) l= expression r= expression )
                    {
                    if ( input.LA(1)==AndLog||input.LA(1)==AndBit ) {
                        input.consume();
                        state.errorRecovery=false;state.failed=false;
                    }
                    else {
                        if (state.backtracking>0) {state.failed=true; return e;}
                        MismatchedSetException mse = new MismatchedSetException(null,input);
                        throw mse;
                    }


                    match(input, Token.DOWN, null); if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2703);
                    l=expression();

                    state._fsp--;
                    if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2707);
                    r=expression();

                    state._fsp--;
                    if (state.failed) return e;

                    match(input, Token.UP, null); if (state.failed) return e;
                    if ( state.backtracking==0 ) {

                      			e = new OpBinary(TypeCode.Boolean,Op.and,l,r);
                      		
                    }

                    }
                    break;
                case 21 :
                    // ANMLTree.g:825:4: ^( ( OrLog | OrBit ) l= expression r= expression )
                    {
                    if ( input.LA(1)==OrLog||input.LA(1)==OrBit ) {
                        input.consume();
                        state.errorRecovery=false;state.failed=false;
                    }
                    else {
                        if (state.backtracking>0) {state.failed=true; return e;}
                        MismatchedSetException mse = new MismatchedSetException(null,input);
                        throw mse;
                    }


                    match(input, Token.DOWN, null); if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2724);
                    l=expression();

                    state._fsp--;
                    if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2728);
                    r=expression();

                    state._fsp--;
                    if (state.failed) return e;

                    match(input, Token.UP, null); if (state.failed) return e;
                    if ( state.backtracking==0 ) {

                      			e = new OpBinary(TypeCode.Boolean,Op.or,l,r);
                      		
                    }

                    }
                    break;
                case 22 :
                    // ANMLTree.g:828:4: ^( Plus l= expression r= expression )
                    {
                    match(input,Plus,FOLLOW_Plus_in_expression2737); if (state.failed) return e;

                    match(input, Token.DOWN, null); if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2741);
                    l=expression();

                    state._fsp--;
                    if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2745);
                    r=expression();

                    state._fsp--;
                    if (state.failed) return e;

                    match(input, Token.UP, null); if (state.failed) return e;
                    if ( state.backtracking==0 ) {

                      			e = new OpBinary(l.typeCode(),Op.add,l,r);
                      		
                    }

                    }
                    break;
                case 23 :
                    // ANMLTree.g:831:4: ^( Minus l= expression r= expression )
                    {
                    match(input,Minus,FOLLOW_Minus_in_expression2754); if (state.failed) return e;

                    match(input, Token.DOWN, null); if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2758);
                    l=expression();

                    state._fsp--;
                    if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2762);
                    r=expression();

                    state._fsp--;
                    if (state.failed) return e;

                    match(input, Token.UP, null); if (state.failed) return e;
                    if ( state.backtracking==0 ) {

                      			e = new OpBinary(l.typeCode(),Op.subtract,l,r);
                      		
                    }

                    }
                    break;
                case 24 :
                    // ANMLTree.g:834:4: ^( Times l= expression r= expression )
                    {
                    match(input,Times,FOLLOW_Times_in_expression2771); if (state.failed) return e;

                    match(input, Token.DOWN, null); if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2775);
                    l=expression();

                    state._fsp--;
                    if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2779);
                    r=expression();

                    state._fsp--;
                    if (state.failed) return e;

                    match(input, Token.UP, null); if (state.failed) return e;
                    if ( state.backtracking==0 ) {

                      			e = new OpBinary(l.typeCode(),Op.multiply,l,r);
                      		
                    }

                    }
                    break;
                case 25 :
                    // ANMLTree.g:837:4: ^( Divide l= expression r= expression )
                    {
                    match(input,Divide,FOLLOW_Divide_in_expression2788); if (state.failed) return e;

                    match(input, Token.DOWN, null); if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2792);
                    l=expression();

                    state._fsp--;
                    if (state.failed) return e;
                    pushFollow(FOLLOW_expression_in_expression2796);
                    r=expression();

                    state._fsp--;
                    if (state.failed) return e;

                    match(input, Token.UP, null); if (state.failed) return e;
                    if ( state.backtracking==0 ) {

                      			e = new OpBinary(l.typeCode(),Op.divide,l,r);
                      		
                    }

                    }
                    break;
                case 26 :
                    // ANMLTree.g:840:4: ^( ForallExpr ^( Parameters scope_arg_decl_list[forall] ) l= expression )
                    {
                    ForallExpr52=(ANMLToken)match(input,ForallExpr,FOLLOW_ForallExpr_in_expression2805); if (state.failed) return e;

                    if ( state.backtracking==0 ) {
                      e = forall = new ForAll(((S_scope)S_stack.peek()).d,ForallExpr52.getSimpleText());
                    }

                    match(input, Token.DOWN, null); if (state.failed) return e;
                    match(input,Parameters,FOLLOW_Parameters_in_expression2814); if (state.failed) return e;

                    if ( input.LA(1)==Token.DOWN ) {
                        match(input, Token.DOWN, null); if (state.failed) return e;
                        pushFollow(FOLLOW_scope_arg_decl_list_in_expression2816);
                        scope_arg_decl_list(forall);

                        state._fsp--;
                        if (state.failed) return e;

                        match(input, Token.UP, null); if (state.failed) return e;
                    }
                    pushFollow(FOLLOW_expression_in_expression2822);
                    l=expression();

                    state._fsp--;
                    if (state.failed) return e;

                    match(input, Token.UP, null); if (state.failed) return e;
                    if ( state.backtracking==0 ) {

                      			forall.addStatement(l);
                      		
                    }

                    }
                    break;
                case 27 :
                    // ANMLTree.g:844:4: ^( ExistsExpr ^( Parameters scope_arg_decl_list[exists] ) l= expression )
                    {
                    ExistsExpr53=(ANMLToken)match(input,ExistsExpr,FOLLOW_ExistsExpr_in_expression2831); if (state.failed) return e;

                    if ( state.backtracking==0 ) {
                      e = exists = new Exists(((S_scope)S_stack.peek()).d,ExistsExpr53.getSimpleText());
                    }

                    match(input, Token.DOWN, null); if (state.failed) return e;
                    match(input,Parameters,FOLLOW_Parameters_in_expression2839); if (state.failed) return e;

                    if ( input.LA(1)==Token.DOWN ) {
                        match(input, Token.DOWN, null); if (state.failed) return e;
                        pushFollow(FOLLOW_scope_arg_decl_list_in_expression2841);
                        scope_arg_decl_list(exists);

                        state._fsp--;
                        if (state.failed) return e;

                        match(input, Token.UP, null); if (state.failed) return e;
                    }
                    pushFollow(FOLLOW_expression_in_expression2847);
                    l=expression();

                    state._fsp--;
                    if (state.failed) return e;

                    match(input, Token.UP, null); if (state.failed) return e;
                    if ( state.backtracking==0 ) {

                      			exists.addStatement(l);
                      		
                    }

                    }
                    break;
                case 28 :
                    // ANMLTree.g:848:4: ^( ContainsSomeExpr interval[te] tl= timed_expression[te] )
                    {
                    match(input,ContainsSomeExpr,FOLLOW_ContainsSomeExpr_in_expression2856); if (state.failed) return e;

                    if ( state.backtracking==0 ) {
                      te = new TimedExpression(); e = new ContainsExpression(te);
                    }

                    match(input, Token.DOWN, null); if (state.failed) return e;
                    pushFollow(FOLLOW_interval_in_expression2862);
                    interval(te);

                    state._fsp--;
                    if (state.failed) return e;
                    pushFollow(FOLLOW_timed_expression_in_expression2867);
                    tl=timed_expression(te);

                    state._fsp--;
                    if (state.failed) return e;
                    if ( state.backtracking==0 ) {

                      			te.e = tl;
                      		
                    }

                    match(input, Token.UP, null); if (state.failed) return e;

                    }
                    break;
                case 29 :
                    // ANMLTree.g:853:4: ^( ContainsAllExpr b= boolean_expression )
                    {
                    match(input,ContainsAllExpr,FOLLOW_ContainsAllExpr_in_expression2881); if (state.failed) return e;

                    match(input, Token.DOWN, null); if (state.failed) return e;
                    pushFollow(FOLLOW_boolean_expression_in_expression2885);
                    b=boolean_expression();

                    state._fsp--;
                    if (state.failed) return e;
                    if ( state.backtracking==0 ) {

                      			e = new ContainsExpression(new TimeOfExpression(b));
                      		
                    }

                    match(input, Token.UP, null); if (state.failed) return e;

                    }
                    break;
                case 30 :
                    // ANMLTree.g:857:4: ^( TimedExpr interval[te] tl= timed_expression[te] )
                    {
                    match(input,TimedExpr,FOLLOW_TimedExpr_in_expression2898); if (state.failed) return e;

                    if ( state.backtracking==0 ) {
                      e = te = new TimedExpression();
                    }

                    match(input, Token.DOWN, null); if (state.failed) return e;
                    pushFollow(FOLLOW_interval_in_expression2902);
                    interval(te);

                    state._fsp--;
                    if (state.failed) return e;
                    pushFollow(FOLLOW_timed_expression_in_expression2907);
                    tl=timed_expression(te);

                    state._fsp--;
                    if (state.failed) return e;
                    if ( state.backtracking==0 ) {
                      te.e = tl;
                    }

                    match(input, Token.UP, null); if (state.failed) return e;

                    }
                    break;
                case 31 :
                    // ANMLTree.g:858:4: ^( Unordered (b= boolean_expression )* )
                    {
                    match(input,Unordered,FOLLOW_Unordered_in_expression2917); if (state.failed) return e;

                    if ( state.backtracking==0 ) {
                      e = unordered = new Unordered();
                    }

                    if ( input.LA(1)==Token.DOWN ) {
                        match(input, Token.DOWN, null); if (state.failed) return e;
                        // ANMLTree.g:858:52: (b= boolean_expression )*
                        loop49:
                        do {
                            int alt49=2;
                            int LA49_0 = input.LA(1);

                            if ( ((LA49_0>=LabelRef && LA49_0<=Access)||LA49_0==Label||(LA49_0>=Bra && LA49_0<=Ket)||LA49_0==TimedExpr||(LA49_0>=ContainsSomeExpr && LA49_0<=ContainsAllExpr)||LA49_0==ExistsExpr||LA49_0==ID||(LA49_0>=LessThan && LA49_0<=Assign)||LA49_0==Undefine||(LA49_0>=NotLog && LA49_0<=Equal)||LA49_0==Duration||(LA49_0>=Change && LA49_0<=Delta)||(LA49_0>=Implies && LA49_0<=Ordered)||(LA49_0>=Start && LA49_0<=GreaterThanE)||LA49_0==ForallExpr) ) {
                                alt49=1;
                            }


                            switch (alt49) {
                        	case 1 :
                        	    // ANMLTree.g:858:53: b= boolean_expression
                        	    {
                        	    pushFollow(FOLLOW_boolean_expression_in_expression2924);
                        	    b=boolean_expression();

                        	    state._fsp--;
                        	    if (state.failed) return e;
                        	    if ( state.backtracking==0 ) {
                        	      unordered.add(b);
                        	    }

                        	    }
                        	    break;

                        	default :
                        	    break loop49;
                            }
                        } while (true);


                        match(input, Token.UP, null); if (state.failed) return e;
                    }

                    }
                    break;
                case 32 :
                    // ANMLTree.g:859:4: ^( Ordered (b= boolean_expression )* )
                    {
                    match(input,Ordered,FOLLOW_Ordered_in_expression2935); if (state.failed) return e;

                    if ( state.backtracking==0 ) {
                      e = ordered = new Ordered();
                    }

                    if ( input.LA(1)==Token.DOWN ) {
                        match(input, Token.DOWN, null); if (state.failed) return e;
                        // ANMLTree.g:859:46: (b= boolean_expression )*
                        loop50:
                        do {
                            int alt50=2;
                            int LA50_0 = input.LA(1);

                            if ( ((LA50_0>=LabelRef && LA50_0<=Access)||LA50_0==Label||(LA50_0>=Bra && LA50_0<=Ket)||LA50_0==TimedExpr||(LA50_0>=ContainsSomeExpr && LA50_0<=ContainsAllExpr)||LA50_0==ExistsExpr||LA50_0==ID||(LA50_0>=LessThan && LA50_0<=Assign)||LA50_0==Undefine||(LA50_0>=NotLog && LA50_0<=Equal)||LA50_0==Duration||(LA50_0>=Change && LA50_0<=Delta)||(LA50_0>=Implies && LA50_0<=Ordered)||(LA50_0>=Start && LA50_0<=GreaterThanE)||LA50_0==ForallExpr) ) {
                                alt50=1;
                            }


                            switch (alt50) {
                        	case 1 :
                        	    // ANMLTree.g:859:47: b= boolean_expression
                        	    {
                        	    pushFollow(FOLLOW_boolean_expression_in_expression2942);
                        	    b=boolean_expression();

                        	    state._fsp--;
                        	    if (state.failed) return e;
                        	    if ( state.backtracking==0 ) {
                        	      ordered.add(b);
                        	    }

                        	    }
                        	    break;

                        	default :
                        	    break loop50;
                            }
                        } while (true);


                        match(input, Token.UP, null); if (state.failed) return e;
                    }

                    }
                    break;
                case 33 :
                    // ANMLTree.g:860:4: ^( ( NotLog | NotBit ) ( ( ref )=> ref | l= expression ) )
                    {
                    if ( (input.LA(1)>=NotLog && input.LA(1)<=NotBit) ) {
                        input.consume();
                        state.errorRecovery=false;state.failed=false;
                    }
                    else {
                        if (state.backtracking>0) {state.failed=true; return e;}
                        MismatchedSetException mse = new MismatchedSetException(null,input);
                        throw mse;
                    }


                    match(input, Token.DOWN, null); if (state.failed) return e;
                    // ANMLTree.g:861:3: ( ( ref )=> ref | l= expression )
                    int alt51=2;
                    alt51 = dfa51.predict(input);
                    switch (alt51) {
                        case 1 :
                            // ANMLTree.g:861:5: ( ref )=> ref
                            {
                            pushFollow(FOLLOW_ref_in_expression2969);
                            ref54=ref();

                            state._fsp--;
                            if (state.failed) return e;
                            if ( state.backtracking==0 ) {

                              			e = ref54;
                              			ref54.op = Op.refNot;
                              			
                            }

                            }
                            break;
                        case 2 :
                            // ANMLTree.g:865:5: l= expression
                            {
                            pushFollow(FOLLOW_expression_in_expression2979);
                            l=expression();

                            state._fsp--;
                            if (state.failed) return e;
                            if ( state.backtracking==0 ) {

                              			e = new OpUnary(TypeCode.Boolean,Op.not,l);
                              			
                            }

                            }
                            break;

                    }


                    match(input, Token.UP, null); if (state.failed) return e;

                    }
                    break;
                case 34 :
                    // ANMLTree.g:870:4: ref
                    {
                    pushFollow(FOLLOW_ref_in_expression2995);
                    ref55=ref();

                    state._fsp--;
                    if (state.failed) return e;
                    if ( state.backtracking==0 ) {
                       e = ref55; 
                    }

                    }
                    break;
                case 35 :
                    // ANMLTree.g:871:4: ^( Delta ref )
                    {
                    match(input,Delta,FOLLOW_Delta_in_expression3003); if (state.failed) return e;

                    match(input, Token.DOWN, null); if (state.failed) return e;
                    pushFollow(FOLLOW_ref_in_expression3005);
                    ref();

                    state._fsp--;
                    if (state.failed) return e;

                    match(input, Token.UP, null); if (state.failed) return e;

                    }
                    break;
                case 36 :
                    // ANMLTree.g:872:4: literal
                    {
                    pushFollow(FOLLOW_literal_in_expression3011);
                    literal56=literal();

                    state._fsp--;
                    if (state.failed) return e;
                    if ( state.backtracking==0 ) {
                       e = literal56; 
                    }

                    }
                    break;
                case 37 :
                    // ANMLTree.g:873:4: time_primitive
                    {
                    pushFollow(FOLLOW_time_primitive_in_expression3018);
                    time_primitive57=time_primitive();

                    state._fsp--;
                    if (state.failed) return e;
                    if ( state.backtracking==0 ) {
                       e = time_primitive57; 
                    }

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return e;
    }
    // $ANTLR end "expression"


    // $ANTLR start "ref"
    // ANMLTree.g:876:1: ref returns [OpUnary e] : ( identifier_ref | field_ref | term_ref );
    public final OpUnary ref() throws RecognitionException {
        OpUnary e = null;

        Identifier<?,?> identifier_ref58 = null;

        Expression field_ref59 = null;

        Expression term_ref60 = null;


        e = new OpUnary(TypeCode.Boolean,Op.ref,null);
        try {
            // ANMLTree.g:878:1: ( identifier_ref | field_ref | term_ref )
            int alt53=3;
            switch ( input.LA(1) ) {
            case Ref:
                {
                alt53=1;
                }
                break;
            case Access:
                {
                alt53=2;
                }
                break;
            case Bind:
                {
                alt53=3;
                }
                break;
            default:
                if (state.backtracking>0) {state.failed=true; return e;}
                NoViableAltException nvae =
                    new NoViableAltException("", 53, 0, input);

                throw nvae;
            }

            switch (alt53) {
                case 1 :
                    // ANMLTree.g:879:4: identifier_ref
                    {
                    pushFollow(FOLLOW_identifier_ref_in_ref3041);
                    identifier_ref58=identifier_ref();

                    state._fsp--;
                    if (state.failed) return e;
                    if ( state.backtracking==0 ) {
                       e.exp = identifier_ref58; e.baseType = e.exp.typeCode(); 
                    }

                    }
                    break;
                case 2 :
                    // ANMLTree.g:880:4: field_ref
                    {
                    pushFollow(FOLLOW_field_ref_in_ref3048);
                    field_ref59=field_ref();

                    state._fsp--;
                    if (state.failed) return e;
                    if ( state.backtracking==0 ) {
                       e.exp = field_ref59; e.baseType = e.exp.typeCode();
                    }

                    }
                    break;
                case 3 :
                    // ANMLTree.g:881:4: term_ref
                    {
                    pushFollow(FOLLOW_term_ref_in_ref3055);
                    term_ref60=term_ref();

                    state._fsp--;
                    if (state.failed) return e;
                    if ( state.backtracking==0 ) {
                       e.exp = term_ref60; e.baseType = e.exp.typeCode();
                    }

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return e;
    }
    // $ANTLR end "ref"


    // $ANTLR start "identifier_ref"
    // ANMLTree.g:884:1: identifier_ref returns [Identifier<?,?> i] : ^( Ref id ) ;
    public final Identifier<?,?> identifier_ref() throws RecognitionException {
        Identifier<?,?> i = null;

        SimpleString id61 = null;


        try {
            // ANMLTree.g:885:1: ( ^( Ref id ) )
            // ANMLTree.g:886:2: ^( Ref id )
            {
            match(input,Ref,FOLLOW_Ref_in_identifier_ref3073); if (state.failed) return i;

            match(input, Token.DOWN, null); if (state.failed) return i;
            pushFollow(FOLLOW_id_in_identifier_ref3075);
            id61=id();

            state._fsp--;
            if (state.failed) return i;

            match(input, Token.UP, null); if (state.failed) return i;
            if ( state.backtracking==0 ) {
               
              		i =((S_scope)S_stack.peek()).d.resolveSymbol(id61); 
              		if (i == null) {
              			System.err.println("Undeclared identifier in " + ((A_scope)A_stack.peek()).d.name() + ": " + id61); 
              			((S_scope)S_stack.peek()).d.addSymbol(i=new SymbolLiteral(id61));
              		}
              		//System.out.println(((Domain)((A_scope)A_stack.peek()).d.parent).name()); 
              	
            }

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return i;
    }
    // $ANTLR end "identifier_ref"


    // $ANTLR start "field_ref"
    // ANMLTree.g:897:1: field_ref returns [Expression f] : ^( Access ref identifier_ref ) ;
    public final Expression field_ref() throws RecognitionException {
        Expression f = null;

        Identifier<?,?> identifier_ref62 = null;


        try {
            // ANMLTree.g:898:1: ( ^( Access ref identifier_ref ) )
            // ANMLTree.g:899:2: ^( Access ref identifier_ref )
            {
            match(input,Access,FOLLOW_Access_in_field_ref3094); if (state.failed) return f;

            match(input, Token.DOWN, null); if (state.failed) return f;
            pushFollow(FOLLOW_ref_in_field_ref3096);
            ref();

            state._fsp--;
            if (state.failed) return f;
            pushFollow(FOLLOW_identifier_ref_in_field_ref3098);
            identifier_ref62=identifier_ref();

            state._fsp--;
            if (state.failed) return f;

            match(input, Token.UP, null); if (state.failed) return f;
            if ( state.backtracking==0 ) {

              		f = identifier_ref62;
              	
            }

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return f;
    }
    // $ANTLR end "field_ref"


    // $ANTLR start "term_ref"
    // ANMLTree.g:907:1: term_ref returns [Expression t] : ^( Bind r= identifier_ref bind_arg_list[b] ) ;
    public final Expression term_ref() throws RecognitionException {
        Expression t = null;

        Identifier<?,?> r = null;


         Bind<?,?,?> b=null; LabeledExpression l; 
        try {
            // ANMLTree.g:909:1: ( ^( Bind r= identifier_ref bind_arg_list[b] ) )
            // ANMLTree.g:910:2: ^( Bind r= identifier_ref bind_arg_list[b] )
            {
            match(input,Bind,FOLLOW_Bind_in_term_ref3124); if (state.failed) return t;

            match(input, Token.DOWN, null); if (state.failed) return t;
            pushFollow(FOLLOW_identifier_ref_in_term_ref3128);
            r=identifier_ref();

            state._fsp--;
            if (state.failed) return t;
            if ( state.backtracking==0 ) {

              			switch (r.idCode()) {
              			case Action:
              				ActionReference ar;
              				t = b = ar = new ActionReference((Action) r);
              				if (((A_scope)A_stack.peek()).d.labels.get(r.name()) == null) {
              					l = new LabeledExpression(r.name(),ar);
              					((A_scope)A_stack.peek()).d.labels.put(l);
              				}
              				break;
              			case FluentFunction:
              				t = b = new FluentFunctionReference((FluentFunction)r);
              				break;
              			case ConstantFunction:
              				t = b = new ConstantFunctionReference((ConstantFunction)r);
              				break;
              			// just in case we (partially) realize that a 0-arity function is not a function
              			case Fluent:
              				t = r;
              				break;
              			case Constant:
              				t = r;
              				break;
              			default:
              				t = null;
              			}
              		
            }
            pushFollow(FOLLOW_bind_arg_list_in_term_ref3135);
            bind_arg_list(b);

            state._fsp--;
            if (state.failed) return t;

            match(input, Token.UP, null); if (state.failed) return t;

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return t;
    }
    // $ANTLR end "term_ref"


    // $ANTLR start "bind_arg_list"
    // ANMLTree.g:942:1: bind_arg_list[Bind<?,?,?> b] : ( ^( Arguments ( expression )* ) | Arguments );
    public final void bind_arg_list(Bind<?,?,?> b) throws RecognitionException {
        Expression<?,?> expression63 = null;


        try {
            // ANMLTree.g:943:1: ( ^( Arguments ( expression )* ) | Arguments )
            int alt55=2;
            int LA55_0 = input.LA(1);

            if ( (LA55_0==Arguments) ) {
                int LA55_1 = input.LA(2);

                if ( (LA55_1==DOWN) ) {
                    alt55=1;
                }
                else if ( (LA55_1==UP) ) {
                    alt55=2;
                }
                else {
                    if (state.backtracking>0) {state.failed=true; return ;}
                    NoViableAltException nvae =
                        new NoViableAltException("", 55, 1, input);

                    throw nvae;
                }
            }
            else {
                if (state.backtracking>0) {state.failed=true; return ;}
                NoViableAltException nvae =
                    new NoViableAltException("", 55, 0, input);

                throw nvae;
            }
            switch (alt55) {
                case 1 :
                    // ANMLTree.g:944:2: ^( Arguments ( expression )* )
                    {
                    match(input,Arguments,FOLLOW_Arguments_in_bind_arg_list3154); if (state.failed) return ;

                    if ( input.LA(1)==Token.DOWN ) {
                        match(input, Token.DOWN, null); if (state.failed) return ;
                        // ANMLTree.g:944:14: ( expression )*
                        loop54:
                        do {
                            int alt54=2;
                            int LA54_0 = input.LA(1);

                            if ( ((LA54_0>=LabelRef && LA54_0<=Access)||LA54_0==Label||(LA54_0>=Bra && LA54_0<=Ket)||LA54_0==TimedExpr||(LA54_0>=ContainsSomeExpr && LA54_0<=ContainsAllExpr)||LA54_0==ExistsExpr||LA54_0==ID||(LA54_0>=LessThan && LA54_0<=Assign)||LA54_0==Undefine||(LA54_0>=NotLog && LA54_0<=Equal)||LA54_0==Duration||(LA54_0>=Change && LA54_0<=Delta)||(LA54_0>=Implies && LA54_0<=Ordered)||(LA54_0>=Start && LA54_0<=GreaterThanE)||LA54_0==ForallExpr) ) {
                                alt54=1;
                            }


                            switch (alt54) {
                        	case 1 :
                        	    // ANMLTree.g:944:15: expression
                        	    {
                        	    pushFollow(FOLLOW_expression_in_bind_arg_list3157);
                        	    expression63=expression();

                        	    state._fsp--;
                        	    if (state.failed) return ;
                        	    if ( state.backtracking==0 ) {
                        	      b.addArgument((Expression<? extends SimpleObject<?>,?>)expression63);
                        	    }

                        	    }
                        	    break;

                        	default :
                        	    break loop54;
                            }
                        } while (true);


                        match(input, Token.UP, null); if (state.failed) return ;
                    }

                    }
                    break;
                case 2 :
                    // ANMLTree.g:945:4: Arguments
                    {
                    match(input,Arguments,FOLLOW_Arguments_in_bind_arg_list3168); if (state.failed) return ;

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "bind_arg_list"


    // $ANTLR start "time_primitive"
    // ANMLTree.g:949:1: time_primitive returns [Expression e] : ( ^( LabelRef id ( Start | End | Duration | Bra | Ket ) ) | Start | End | Duration | Bra | Ket );
    public final Expression time_primitive() throws RecognitionException {
        Expression e = null;

        SimpleString id64 = null;


        try {
            // ANMLTree.g:950:2: ( ^( LabelRef id ( Start | End | Duration | Bra | Ket ) ) | Start | End | Duration | Bra | Ket )
            int alt57=6;
            switch ( input.LA(1) ) {
            case LabelRef:
                {
                alt57=1;
                }
                break;
            case Start:
                {
                alt57=2;
                }
                break;
            case End:
                {
                alt57=3;
                }
                break;
            case Duration:
                {
                alt57=4;
                }
                break;
            case Bra:
                {
                alt57=5;
                }
                break;
            case Ket:
                {
                alt57=6;
                }
                break;
            default:
                if (state.backtracking>0) {state.failed=true; return e;}
                NoViableAltException nvae =
                    new NoViableAltException("", 57, 0, input);

                throw nvae;
            }

            switch (alt57) {
                case 1 :
                    // ANMLTree.g:950:4: ^( LabelRef id ( Start | End | Duration | Bra | Ket ) )
                    {
                    match(input,LabelRef,FOLLOW_LabelRef_in_time_primitive3184); if (state.failed) return e;

                    match(input, Token.DOWN, null); if (state.failed) return e;
                    pushFollow(FOLLOW_id_in_time_primitive3186);
                    id64=id();

                    state._fsp--;
                    if (state.failed) return e;
                    // ANMLTree.g:951:4: ( Start | End | Duration | Bra | Ket )
                    int alt56=5;
                    switch ( input.LA(1) ) {
                    case Start:
                        {
                        alt56=1;
                        }
                        break;
                    case End:
                        {
                        alt56=2;
                        }
                        break;
                    case Duration:
                        {
                        alt56=3;
                        }
                        break;
                    case Bra:
                        {
                        alt56=4;
                        }
                        break;
                    case Ket:
                        {
                        alt56=5;
                        }
                        break;
                    default:
                        if (state.backtracking>0) {state.failed=true; return e;}
                        NoViableAltException nvae =
                            new NoViableAltException("", 56, 0, input);

                        throw nvae;
                    }

                    switch (alt56) {
                        case 1 :
                            // ANMLTree.g:951:6: Start
                            {
                            match(input,Start,FOLLOW_Start_in_time_primitive3194); if (state.failed) return e;
                            if ( state.backtracking==0 ) {
                               e = ((A_scope)A_stack.peek()).d.labels.get(id64).getStart(); 
                            }

                            }
                            break;
                        case 2 :
                            // ANMLTree.g:952:6: End
                            {
                            match(input,End,FOLLOW_End_in_time_primitive3203); if (state.failed) return e;
                            if ( state.backtracking==0 ) {
                               e = ((A_scope)A_stack.peek()).d.labels.get(id64).getEnd(); 
                            }

                            }
                            break;
                        case 3 :
                            // ANMLTree.g:953:6: Duration
                            {
                            match(input,Duration,FOLLOW_Duration_in_time_primitive3212); if (state.failed) return e;
                            if ( state.backtracking==0 ) {
                               e = ((A_scope)A_stack.peek()).d.labels.get(id64).getDuration(); 
                            }

                            }
                            break;
                        case 4 :
                            // ANMLTree.g:954:6: Bra
                            {
                            match(input,Bra,FOLLOW_Bra_in_time_primitive3221); if (state.failed) return e;
                            if ( state.backtracking==0 ) {
                               e = ((A_scope)A_stack.peek()).d.labels.get(id64).getBra(); 
                            }

                            }
                            break;
                        case 5 :
                            // ANMLTree.g:955:6: Ket
                            {
                            match(input,Ket,FOLLOW_Ket_in_time_primitive3230); if (state.failed) return e;
                            if ( state.backtracking==0 ) {
                               e = ((A_scope)A_stack.peek()).d.labels.get(id64).getKet(); 
                            }

                            }
                            break;

                    }


                    match(input, Token.UP, null); if (state.failed) return e;

                    }
                    break;
                case 2 :
                    // ANMLTree.g:958:4: Start
                    {
                    match(input,Start,FOLLOW_Start_in_time_primitive3246); if (state.failed) return e;
                    if ( state.backtracking==0 ) {
                       e = ((I_scope)I_stack.peek()).i.getStart(); 
                    }

                    }
                    break;
                case 3 :
                    // ANMLTree.g:959:4: End
                    {
                    match(input,End,FOLLOW_End_in_time_primitive3253); if (state.failed) return e;
                    if ( state.backtracking==0 ) {
                       e = ((I_scope)I_stack.peek()).i.getEnd(); 
                    }

                    }
                    break;
                case 4 :
                    // ANMLTree.g:960:4: Duration
                    {
                    match(input,Duration,FOLLOW_Duration_in_time_primitive3261); if (state.failed) return e;
                    if ( state.backtracking==0 ) {
                       e = ((I_scope)I_stack.peek()).i.getDuration(); 
                    }

                    }
                    break;
                case 5 :
                    // ANMLTree.g:961:4: Bra
                    {
                    match(input,Bra,FOLLOW_Bra_in_time_primitive3268); if (state.failed) return e;
                    if ( state.backtracking==0 ) {
                       e = ((I_scope)I_stack.peek()).i.getBra(); 
                    }

                    }
                    break;
                case 6 :
                    // ANMLTree.g:962:4: Ket
                    {
                    match(input,Ket,FOLLOW_Ket_in_time_primitive3275); if (state.failed) return e;
                    if ( state.backtracking==0 ) {
                       e = ((I_scope)I_stack.peek()).i.getKet(); 
                    }

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return e;
    }
    // $ANTLR end "time_primitive"


    // $ANTLR start "set"
    // ANMLTree.g:965:1: set returns [Constraint constraint] : ( enumeration | range );
    public final Constraint set() throws RecognitionException {
        Constraint constraint = null;

        ANMLTree.enumeration_return enumeration65 = null;

        Range range66 = null;


        try {
            // ANMLTree.g:966:1: ( enumeration | range )
            int alt58=2;
            int LA58_0 = input.LA(1);

            if ( (LA58_0==Enum) ) {
                alt58=1;
            }
            else if ( (LA58_0==Range) ) {
                alt58=2;
            }
            else {
                if (state.backtracking>0) {state.failed=true; return constraint;}
                NoViableAltException nvae =
                    new NoViableAltException("", 58, 0, input);

                throw nvae;
            }
            switch (alt58) {
                case 1 :
                    // ANMLTree.g:967:4: enumeration
                    {
                    pushFollow(FOLLOW_enumeration_in_set3295);
                    enumeration65=enumeration();

                    state._fsp--;
                    if (state.failed) return constraint;
                    if ( state.backtracking==0 ) {
                      constraint = (enumeration65!=null?enumeration65.constraint:null);
                    }

                    }
                    break;
                case 2 :
                    // ANMLTree.g:968:4: range
                    {
                    pushFollow(FOLLOW_range_in_set3302);
                    range66=range();

                    state._fsp--;
                    if (state.failed) return constraint;
                    if ( state.backtracking==0 ) {
                       constraint = range66;
                    }

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return constraint;
    }
    // $ANTLR end "set"

    public static class enumeration_return extends TreeRuleReturnScope {
        public Enumeration constraint;
        public TypeCode typeCode;
    };

    // $ANTLR start "enumeration"
    // ANMLTree.g:971:1: enumeration returns [Enumeration constraint, TypeCode typeCode] : ^( Enum f= expression (n= expression )* ) ;
    public final ANMLTree.enumeration_return enumeration() throws RecognitionException {
        ANMLTree.enumeration_return retval = new ANMLTree.enumeration_return();
        retval.start = input.LT(1);

        Expression<?,?> f = null;

        Expression<?,?> n = null;


         Expression<?,?> e;
        try {
            // ANMLTree.g:973:1: ( ^( Enum f= expression (n= expression )* ) )
            // ANMLTree.g:974:2: ^( Enum f= expression (n= expression )* )
            {
            match(input,Enum,FOLLOW_Enum_in_enumeration3325); if (state.failed) return retval;

            match(input, Token.DOWN, null); if (state.failed) return retval;
            pushFollow(FOLLOW_expression_in_enumeration3329);
            f=expression();

            state._fsp--;
            if (state.failed) return retval;
            if ( state.backtracking==0 ) {

              			e = f;
              			retval.typeCode = e.typeCode();
              			retval.constraint = new Enumeration();
              			retval.constraint.add(e.value(null));
              		
            }
            // ANMLTree.g:980:3: (n= expression )*
            loop59:
            do {
                int alt59=2;
                int LA59_0 = input.LA(1);

                if ( ((LA59_0>=LabelRef && LA59_0<=Access)||LA59_0==Label||(LA59_0>=Bra && LA59_0<=Ket)||LA59_0==TimedExpr||(LA59_0>=ContainsSomeExpr && LA59_0<=ContainsAllExpr)||LA59_0==ExistsExpr||LA59_0==ID||(LA59_0>=LessThan && LA59_0<=Assign)||LA59_0==Undefine||(LA59_0>=NotLog && LA59_0<=Equal)||LA59_0==Duration||(LA59_0>=Change && LA59_0<=Delta)||(LA59_0>=Implies && LA59_0<=Ordered)||(LA59_0>=Start && LA59_0<=GreaterThanE)||LA59_0==ForallExpr) ) {
                    alt59=1;
                }


                switch (alt59) {
            	case 1 :
            	    // ANMLTree.g:980:4: n= expression
            	    {
            	    pushFollow(FOLLOW_expression_in_enumeration3339);
            	    n=expression();

            	    state._fsp--;
            	    if (state.failed) return retval;
            	    if ( state.backtracking==0 ) {

            	      				e = n;
            	      				retval.constraint.add(e.value(null));
            	      			
            	    }

            	    }
            	    break;

            	default :
            	    break loop59;
                }
            } while (true);


            match(input, Token.UP, null); if (state.failed) return retval;

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "enumeration"


    // $ANTLR start "range"
    // ANMLTree.g:988:1: range returns [Range constraint] : ^( Range l= expression h= expression ) ;
    public final Range range() throws RecognitionException {
        Range constraint = null;

        Expression<?,?> l = null;

        Expression<?,?> h = null;


        try {
            // ANMLTree.g:989:1: ( ^( Range l= expression h= expression ) )
            // ANMLTree.g:990:2: ^( Range l= expression h= expression )
            {
            match(input,Range,FOLLOW_Range_in_range3365); if (state.failed) return constraint;

            match(input, Token.DOWN, null); if (state.failed) return constraint;
            pushFollow(FOLLOW_expression_in_range3369);
            l=expression();

            state._fsp--;
            if (state.failed) return constraint;
            pushFollow(FOLLOW_expression_in_range3373);
            h=expression();

            state._fsp--;
            if (state.failed) return constraint;
            if ( state.backtracking==0 ) {

              			constraint = new Range<SimpleObject>((SimpleObject)l.value(null),(SimpleObject)h.value(null));
              		
            }

            match(input, Token.UP, null); if (state.failed) return constraint;

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return constraint;
    }
    // $ANTLR end "range"


    // $ANTLR start "literal"
    // ANMLTree.g:996:1: literal returns [Expression e] : (t= INT | t= FLOAT | t= STRING | t= True | t= False | t= Infinity | t= ID );
    public final Expression literal() throws RecognitionException {
        Expression e = null;

        ANMLToken t=null;

        try {
            // ANMLTree.g:997:2: (t= INT | t= FLOAT | t= STRING | t= True | t= False | t= Infinity | t= ID )
            int alt60=7;
            switch ( input.LA(1) ) {
            case INT:
                {
                alt60=1;
                }
                break;
            case FLOAT:
                {
                alt60=2;
                }
                break;
            case STRING:
                {
                alt60=3;
                }
                break;
            case True:
                {
                alt60=4;
                }
                break;
            case False:
                {
                alt60=5;
                }
                break;
            case Infinity:
                {
                alt60=6;
                }
                break;
            case ID:
                {
                alt60=7;
                }
                break;
            default:
                if (state.backtracking>0) {state.failed=true; return e;}
                NoViableAltException nvae =
                    new NoViableAltException("", 60, 0, input);

                throw nvae;
            }

            switch (alt60) {
                case 1 :
                    // ANMLTree.g:997:4: t= INT
                    {
                    t=(ANMLToken)match(input,INT,FOLLOW_INT_in_literal3395); if (state.failed) return e;
                    if ( state.backtracking==0 ) {
                       e = ANMLInteger.make(java.lang.Integer.parseInt(t.getText())); 
                    }

                    }
                    break;
                case 2 :
                    // ANMLTree.g:998:4: t= FLOAT
                    {
                    t=(ANMLToken)match(input,FLOAT,FOLLOW_FLOAT_in_literal3404); if (state.failed) return e;
                    if ( state.backtracking==0 ) {
                       e = ANMLFloat.make(java.lang.Float.parseFloat(t.getText())); 
                    }

                    }
                    break;
                case 3 :
                    // ANMLTree.g:999:4: t= STRING
                    {
                    t=(ANMLToken)match(input,STRING,FOLLOW_STRING_in_literal3413); if (state.failed) return e;
                    if ( state.backtracking==0 ) {
                       e = ANMLString.make(t.getSimpleText().v); 
                    }

                    }
                    break;
                case 4 :
                    // ANMLTree.g:1000:4: t= True
                    {
                    t=(ANMLToken)match(input,True,FOLLOW_True_in_literal3423); if (state.failed) return e;
                    if ( state.backtracking==0 ) {
                       e = ANMLBoolean.True; 
                    }

                    }
                    break;
                case 5 :
                    // ANMLTree.g:1001:4: t= False
                    {
                    t=(ANMLToken)match(input,False,FOLLOW_False_in_literal3432); if (state.failed) return e;
                    if ( state.backtracking==0 ) {
                       e = ANMLBoolean.False; 
                    }

                    }
                    break;
                case 6 :
                    // ANMLTree.g:1002:4: t= Infinity
                    {
                    t=(ANMLToken)match(input,Infinity,FOLLOW_Infinity_in_literal3441); if (state.failed) return e;
                    if ( state.backtracking==0 ) {
                       e = ANMLFloat.PInf; 
                    }

                    }
                    break;
                case 7 :
                    // ANMLTree.g:1003:4: t= ID
                    {
                    t=(ANMLToken)match(input,ID,FOLLOW_ID_in_literal3451); if (state.failed) return e;
                    if ( state.backtracking==0 ) {
                       e = ANMLString.make(t.getSimpleText().v); 
                    }

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return e;
    }
    // $ANTLR end "literal"

    // $ANTLR start synpred1_ANMLTree
    public final void synpred1_ANMLTree_fragment() throws RecognitionException {   
        // ANMLTree.g:861:5: ( ref )
        // ANMLTree.g:861:6: ref
        {
        pushFollow(FOLLOW_ref_in_synpred1_ANMLTree2965);
        ref();

        state._fsp--;
        if (state.failed) return ;

        }
    }
    // $ANTLR end synpred1_ANMLTree

    // Delegated rules

    public final boolean synpred1_ANMLTree() {
        state.backtracking++;
        int start = input.mark();
        try {
            synpred1_ANMLTree_fragment(); // can never throw exception
        } catch (RecognitionException re) {
            System.err.println("impossible: "+re);
        }
        boolean success = !state.failed;
        input.rewind(start);
        state.backtracking--;
        state.failed=false;
        return success;
    }


    protected DFA16 dfa16 = new DFA16(this);
    protected DFA51 dfa51 = new DFA51(this);
    static final String DFA16_eotS =
        "\14\uffff";
    static final String DFA16_eofS =
        "\14\uffff";
    static final String DFA16_minS =
        "\1\15\1\2\1\70\6\3\3\uffff";
    static final String DFA16_maxS =
        "\1\15\1\2\1\77\6\67\3\uffff";
    static final String DFA16_acceptS =
        "\11\uffff\1\3\1\1\1\2";
    static final String DFA16_specialS =
        "\14\uffff}>";
    static final String[] DFA16_transitionS = {
            "\1\1",
            "\1\2",
            "\2\11\1\3\1\4\1\5\1\6\1\7\1\10",
            "\1\12\62\uffff\2\13",
            "\1\12\62\uffff\2\13",
            "\1\12\62\uffff\2\13",
            "\1\12\62\uffff\2\13",
            "\1\12\62\uffff\2\13",
            "\1\12\62\uffff\2\13",
            "",
            "",
            ""
    };

    static final short[] DFA16_eot = DFA.unpackEncodedString(DFA16_eotS);
    static final short[] DFA16_eof = DFA.unpackEncodedString(DFA16_eofS);
    static final char[] DFA16_min = DFA.unpackEncodedStringToUnsignedChars(DFA16_minS);
    static final char[] DFA16_max = DFA.unpackEncodedStringToUnsignedChars(DFA16_maxS);
    static final short[] DFA16_accept = DFA.unpackEncodedString(DFA16_acceptS);
    static final short[] DFA16_special = DFA.unpackEncodedString(DFA16_specialS);
    static final short[][] DFA16_transition;

    static {
        int numStates = DFA16_transitionS.length;
        DFA16_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA16_transition[i] = DFA.unpackEncodedString(DFA16_transitionS[i]);
        }
    }

    class DFA16 extends DFA {

        public DFA16(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 16;
            this.eot = DFA16_eot;
            this.eof = DFA16_eof;
            this.min = DFA16_min;
            this.max = DFA16_max;
            this.accept = DFA16_accept;
            this.special = DFA16_special;
            this.transition = DFA16_transition;
        }
        public String getDescription() {
            return "313:1: type_ref returns [Type d] : ( ^( TypeRef builtinType ) | ^( TypeRef builtinType set ) | ^( TypeRef id ) );";
        }
    }
    static final String DFA51_eotS =
        "\64\uffff";
    static final String DFA51_eofS =
        "\64\uffff";
    static final String DFA51_minS =
        "\1\16\3\0\60\uffff";
    static final String DFA51_maxS =
        "\1\u0089\3\0\60\uffff";
    static final String DFA51_acceptS =
        "\4\uffff\1\2\56\uffff\1\1";
    static final String DFA51_specialS =
        "\1\uffff\1\0\1\1\1\2\60\uffff}>";
    static final String[] DFA51_transitionS = {
            "\1\4\1\1\1\3\1\2\10\uffff\1\4\4\uffff\2\4\12\uffff\1\4\2\uffff"+
            "\2\4\2\uffff\1\4\5\uffff\1\4\11\uffff\2\4\4\uffff\1\4\7\uffff"+
            "\4\4\2\uffff\1\4\6\uffff\11\4\3\uffff\15\4\1\uffff\14\4\6\uffff"+
            "\1\4",
            "\1\uffff",
            "\1\uffff",
            "\1\uffff",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""
    };

    static final short[] DFA51_eot = DFA.unpackEncodedString(DFA51_eotS);
    static final short[] DFA51_eof = DFA.unpackEncodedString(DFA51_eofS);
    static final char[] DFA51_min = DFA.unpackEncodedStringToUnsignedChars(DFA51_minS);
    static final char[] DFA51_max = DFA.unpackEncodedStringToUnsignedChars(DFA51_maxS);
    static final short[] DFA51_accept = DFA.unpackEncodedString(DFA51_acceptS);
    static final short[] DFA51_special = DFA.unpackEncodedString(DFA51_specialS);
    static final short[][] DFA51_transition;

    static {
        int numStates = DFA51_transitionS.length;
        DFA51_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA51_transition[i] = DFA.unpackEncodedString(DFA51_transitionS[i]);
        }
    }

    class DFA51 extends DFA {

        public DFA51(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 51;
            this.eot = DFA51_eot;
            this.eof = DFA51_eof;
            this.min = DFA51_min;
            this.max = DFA51_max;
            this.accept = DFA51_accept;
            this.special = DFA51_special;
            this.transition = DFA51_transition;
        }
        public String getDescription() {
            return "861:3: ( ( ref )=> ref | l= expression )";
        }
        public int specialStateTransition(int s, IntStream _input) throws NoViableAltException {
            TreeNodeStream input = (TreeNodeStream)_input;
        	int _s = s;
            switch ( s ) {
                    case 0 : 
                        int LA51_1 = input.LA(1);

                         
                        int index51_1 = input.index();
                        input.rewind();
                        s = -1;
                        if ( (synpred1_ANMLTree()) ) {s = 51;}

                        else if ( (true) ) {s = 4;}

                         
                        input.seek(index51_1);
                        if ( s>=0 ) return s;
                        break;
                    case 1 : 
                        int LA51_2 = input.LA(1);

                         
                        int index51_2 = input.index();
                        input.rewind();
                        s = -1;
                        if ( (synpred1_ANMLTree()) ) {s = 51;}

                        else if ( (true) ) {s = 4;}

                         
                        input.seek(index51_2);
                        if ( s>=0 ) return s;
                        break;
                    case 2 : 
                        int LA51_3 = input.LA(1);

                         
                        int index51_3 = input.index();
                        input.rewind();
                        s = -1;
                        if ( (synpred1_ANMLTree()) ) {s = 51;}

                        else if ( (true) ) {s = 4;}

                         
                        input.seek(index51_3);
                        if ( s>=0 ) return s;
                        break;
            }
            if (state.backtracking>0) {state.failed=true; return -1;}
            NoViableAltException nvae =
                new NoViableAltException(getDescription(), 51, _s, input);
            error(nvae);
            throw nvae;
        }
    }
 

    public static final BitSet FOLLOW_Block_in_model138 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_types_in_model143 = new BitSet(new long[]{0x0000000000000020L});
    public static final BitSet FOLLOW_constants_in_model148 = new BitSet(new long[]{0x0000000000000040L});
    public static final BitSet FOLLOW_fluents_in_model153 = new BitSet(new long[]{0x0000000000000080L});
    public static final BitSet FOLLOW_actions_in_model158 = new BitSet(new long[]{0x0000000000000400L});
    public static final BitSet FOLLOW_stmts_in_model163 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Parameter_in_term_arg_decl_list181 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_id_in_term_arg_decl_list183 = new BitSet(new long[]{0x0000000000002000L});
    public static final BitSet FOLLOW_type_ref_in_term_arg_decl_list185 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Parameter_in_scope_arg_decl_list211 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_id_in_scope_arg_decl_list213 = new BitSet(new long[]{0x0000000000002000L});
    public static final BitSet FOLLOW_type_ref_in_scope_arg_decl_list215 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Boolean_in_builtinType250 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_Integer_in_builtinType259 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_Float_in_builtinType268 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_Symbol_in_builtinType277 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_String_in_builtinType286 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_Object_in_builtinType295 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_ID_in_id319 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_This_in_id329 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_Vector_in_type_spec355 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_Parameters_in_type_spec367 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_term_arg_decl_list_in_type_spec369 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Parameters_in_type_spec375 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_TypeRef_in_type_spec389 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_builtinType_in_type_spec391 = new BitSet(new long[]{0x00C0000000000008L});
    public static final BitSet FOLLOW_set_in_type_spec404 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_TypeRef_in_type_spec420 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_id_in_type_spec422 = new BitSet(new long[]{0x00C0000000000008L});
    public static final BitSet FOLLOW_set_in_type_spec438 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_enumeration_in_type_spec453 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_Type_in_type_decl473 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_id_in_type_decl475 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000008L});
    public static final BitSet FOLLOW_Assign_in_type_decl483 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000004L});
    public static final BitSet FOLLOW_Assign_in_type_decl492 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_type_spec_in_type_decl494 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_LessThan_in_type_decl508 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000010L});
    public static final BitSet FOLLOW_LessThan_in_type_decl515 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_type_ref_in_type_decl520 = new BitSet(new long[]{0x0000000000002008L});
    public static final BitSet FOLLOW_With_in_type_decl544 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_With_in_type_decl553 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_object_block_in_type_decl560 = new BitSet(new long[]{0x0000000000000808L});
    public static final BitSet FOLLOW_TypeRefine_in_type_refine586 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_type_ref_in_type_refine590 = new BitSet(new long[]{0x0300000000000000L,0x000000000000001CL});
    public static final BitSet FOLLOW_Assign_in_type_refine598 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_type_spec_in_type_refine600 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_LessThan_in_type_refine610 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_type_ref_in_type_refine614 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_With_in_type_refine623 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_object_block_in_type_refine625 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_id_in_type_refine634 = new BitSet(new long[]{0x0300000000000008L,0x000000000000001CL});
    public static final BitSet FOLLOW_TypeRef_in_type_ref677 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_builtinType_in_type_ref679 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_TypeRef_in_type_ref688 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_builtinType_in_type_ref690 = new BitSet(new long[]{0x00C0000000000000L});
    public static final BitSet FOLLOW_set_in_type_ref692 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_TypeRef_in_type_ref701 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_id_in_type_ref703 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Constant_in_const_decl748 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_id_in_const_decl750 = new BitSet(new long[]{0x0000000000002000L});
    public static final BitSet FOLLOW_type_ref_in_const_decl756 = new BitSet(new long[]{0x0104C8018403C008L,0xFFBFFE3FE04F010CL,0x0000000000000207L});
    public static final BitSet FOLLOW_expression_in_const_decl761 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_ConstantFunction_in_const_decl776 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_id_in_const_decl778 = new BitSet(new long[]{0x0000000000002000L});
    public static final BitSet FOLLOW_type_ref_in_const_decl784 = new BitSet(new long[]{0x0000000000000100L});
    public static final BitSet FOLLOW_Parameters_in_const_decl796 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_term_arg_decl_list_in_const_decl798 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Parameters_in_const_decl804 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Fluent_in_fluent_decl827 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_id_in_fluent_decl829 = new BitSet(new long[]{0x0000000000002000L});
    public static final BitSet FOLLOW_type_ref_in_fluent_decl835 = new BitSet(new long[]{0x0104C8018403C008L,0xFFBFFE3FE04F010CL,0x0000000000000207L});
    public static final BitSet FOLLOW_expression_in_fluent_decl840 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_FluentFunction_in_fluent_decl855 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_id_in_fluent_decl857 = new BitSet(new long[]{0x0000000000002000L});
    public static final BitSet FOLLOW_type_ref_in_fluent_decl863 = new BitSet(new long[]{0x0000000000000100L});
    public static final BitSet FOLLOW_Parameters_in_fluent_decl874 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_term_arg_decl_list_in_fluent_decl876 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Parameters_in_fluent_decl882 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Block_in_object_block917 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_types_in_object_block924 = new BitSet(new long[]{0x0000000000000020L});
    public static final BitSet FOLLOW_constants_in_object_block930 = new BitSet(new long[]{0x0000000000000040L});
    public static final BitSet FOLLOW_fluents_in_object_block936 = new BitSet(new long[]{0x0000000000000080L});
    public static final BitSet FOLLOW_actions_in_object_block942 = new BitSet(new long[]{0x0000000000000400L});
    public static final BitSet FOLLOW_stmts_in_object_block948 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Action_in_action_decl974 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_id_in_action_decl976 = new BitSet(new long[]{0x0000000000000100L});
    public static final BitSet FOLLOW_Parameters_in_action_decl984 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_scope_arg_decl_list_in_action_decl986 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Parameters_in_action_decl992 = new BitSet(new long[]{0x0000000000000010L,0x0000000000400000L});
    public static final BitSet FOLLOW_start_parameter_in_action_decl998 = new BitSet(new long[]{0x0000000000000010L,0x0000000000400000L});
    public static final BitSet FOLLOW_duration_parameter_in_action_decl1003 = new BitSet(new long[]{0x0000000000000010L,0x0000000000400000L});
    public static final BitSet FOLLOW_action_block_in_action_decl1011 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Duration_in_duration_parameter1063 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_types_in_action_block1091 = new BitSet(new long[]{0x0000000000000020L});
    public static final BitSet FOLLOW_constants_in_action_block1094 = new BitSet(new long[]{0x0000000000000040L});
    public static final BitSet FOLLOW_fluents_in_action_block1097 = new BitSet(new long[]{0x0000000000000080L});
    public static final BitSet FOLLOW_actions_in_action_block1100 = new BitSet(new long[]{0x0000000000000400L});
    public static final BitSet FOLLOW_stmts_in_action_block1103 = new BitSet(new long[]{0x0000000000001000L});
    public static final BitSet FOLLOW_decompositions_in_action_block1106 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_Types_in_types1117 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_type_decl_in_types1120 = new BitSet(new long[]{0x00000000000C0008L});
    public static final BitSet FOLLOW_type_refine_in_types1122 = new BitSet(new long[]{0x00000000000C0008L});
    public static final BitSet FOLLOW_Types_in_types1130 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_Constants_in_constants1140 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_const_decl_in_constants1142 = new BitSet(new long[]{0x0000000000C00008L});
    public static final BitSet FOLLOW_Constants_in_constants1150 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_Fluents_in_fluents1160 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_fluent_decl_in_fluents1162 = new BitSet(new long[]{0x0000000000300008L});
    public static final BitSet FOLLOW_Fluents_in_fluents1170 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_Actions_in_actions1181 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_action_decl_in_actions1183 = new BitSet(new long[]{0x0000000002000008L});
    public static final BitSet FOLLOW_Actions_in_actions1190 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_Stmts_in_stmts1201 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_stmts_helper_in_stmts1203 = new BitSet(new long[]{0x013EFE018403C808L,0xFFBFFE3FE04F010CL,0x0000000000000207L});
    public static final BitSet FOLLOW_Stmts_in_stmts1211 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_stmt_in_stmts_helper1219 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_Decompositions_in_decompositions1232 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_decomps_helper_in_decompositions1234 = new BitSet(new long[]{0x0000000000000808L});
    public static final BitSet FOLLOW_Decompositions_in_decompositions1242 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_decomp_in_decomps_helper1250 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_Block_in_decomp1274 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_types_in_decomp1281 = new BitSet(new long[]{0x0000000000000020L});
    public static final BitSet FOLLOW_constants_in_decomp1285 = new BitSet(new long[]{0x0000000000000040L});
    public static final BitSet FOLLOW_fluents_in_decomp1289 = new BitSet(new long[]{0x0000000000000080L});
    public static final BitSet FOLLOW_actions_in_decomp1293 = new BitSet(new long[]{0x0000000000000400L});
    public static final BitSet FOLLOW_stmts_in_decomp1297 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Block_in_block1323 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_types_in_block1330 = new BitSet(new long[]{0x0000000000000020L});
    public static final BitSet FOLLOW_constants_in_block1334 = new BitSet(new long[]{0x0000000000000040L});
    public static final BitSet FOLLOW_fluents_in_block1338 = new BitSet(new long[]{0x0000000000000080L});
    public static final BitSet FOLLOW_actions_in_block1342 = new BitSet(new long[]{0x0000000000000400L});
    public static final BitSet FOLLOW_stmts_in_block1346 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Block_in_sub_block1372 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_types_in_sub_block1377 = new BitSet(new long[]{0x0000000000000020L});
    public static final BitSet FOLLOW_constants_in_sub_block1381 = new BitSet(new long[]{0x0000000000000040L});
    public static final BitSet FOLLOW_fluents_in_sub_block1385 = new BitSet(new long[]{0x0000000000000080L});
    public static final BitSet FOLLOW_actions_in_sub_block1389 = new BitSet(new long[]{0x0000000000000400L});
    public static final BitSet FOLLOW_stmts_in_sub_block1393 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_simple_stmt_in_stmt1412 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_block_in_stmt1419 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_stmt_in_timed_stmt1447 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_When_in_simple_stmt1470 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_simple_stmt1474 = new BitSet(new long[]{0x013EFE018403C808L,0xFFBFFE3FE04F010CL,0x0000000000000207L});
    public static final BitSet FOLLOW_stmt_in_simple_stmt1478 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_WhenElse_in_simple_stmt1487 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_simple_stmt1491 = new BitSet(new long[]{0x013EFE018403C808L,0xFFBFFE3FE04F010CL,0x0000000000000207L});
    public static final BitSet FOLLOW_stmt_in_simple_stmt1495 = new BitSet(new long[]{0x013EFE018403C808L,0xFFBFFE3FE04F010CL,0x0000000000000207L});
    public static final BitSet FOLLOW_stmt_in_simple_stmt1499 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_ForAllStmt_in_simple_stmt1508 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_Parameters_in_simple_stmt1519 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_scope_arg_decl_list_in_simple_stmt1521 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_sub_block_in_simple_stmt1533 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_simple_stmt_in_simple_stmt1545 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_ExistsStmt_in_simple_stmt1565 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_Parameters_in_simple_stmt1576 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_scope_arg_decl_list_in_simple_stmt1578 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_sub_block_in_simple_stmt1589 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_simple_stmt_in_simple_stmt1603 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_ContainsSomeStmt_in_simple_stmt1623 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_interval_in_simple_stmt1625 = new BitSet(new long[]{0x013EFE018403C808L,0xFFBFFE3FE04F010CL,0x0000000000000207L});
    public static final BitSet FOLLOW_timed_stmt_in_simple_stmt1628 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_ContainsAllStmt_in_simple_stmt1636 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_stmt_in_simple_stmt1638 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_TimedStmt_in_simple_stmt1645 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_interval_in_simple_stmt1653 = new BitSet(new long[]{0x013EFE018403C808L,0xFFBFFE3FE04F010CL,0x0000000000000207L});
    public static final BitSet FOLLOW_timed_stmt_in_simple_stmt1656 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Chain_in_simple_stmt1669 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_chain_stmt_in_simple_stmt1671 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_expression_in_simple_stmt1681 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_interval_in_chain_stmt1705 = new BitSet(new long[]{0x0000000000038000L});
    public static final BitSet FOLLOW_ref_in_chain_stmt1708 = new BitSet(new long[]{0x0000000000000000L,0x8000001FE008010CL,0x0000000000000007L});
    public static final BitSet FOLLOW_Equal_in_chain_stmt1716 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_chain_stmt1720 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_NotEqual_in_chain_stmt1729 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_chain_stmt1733 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_LessThan_in_chain_stmt1742 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_chain_stmt1746 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_GreaterThan_in_chain_stmt1755 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_chain_stmt1759 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_LessThanE_in_chain_stmt1768 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_chain_stmt1772 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_GreaterThanE_in_chain_stmt1781 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_chain_stmt1785 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Assign_in_chain_stmt1794 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_chain_stmt1798 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Change_in_chain_stmt1807 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_chain_stmt1811 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Lend_in_chain_stmt1820 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_chain_stmt1824 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Use_in_chain_stmt1833 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_chain_stmt1837 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Produce_in_chain_stmt1846 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_chain_stmt1850 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Consume_in_chain_stmt1859 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_chain_stmt1863 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_SetAssign_in_chain_stmt1872 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_set_in_chain_stmt1874 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Within_in_chain_stmt1883 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_set_in_chain_stmt1885 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Undefine_in_chain_stmt1893 = new BitSet(new long[]{0x0000000000000002L,0x8000001FE008010CL,0x0000000000000007L});
    public static final BitSet FOLLOW_Skip_in_chain_stmt1900 = new BitSet(new long[]{0x0000000000000002L,0x8000001FE008010CL,0x0000000000000007L});
    public static final BitSet FOLLOW_expression_in_float_expression1920 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_expression_in_boolean_expression1938 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_DefiniteInterval_in_interval1958 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_bra_in_interval1962 = new BitSet(new long[]{0x0000014000000000L});
    public static final BitSet FOLLOW_TDuration_in_interval1970 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_float_expression_in_interval1974 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_TEnd_in_interval1978 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_float_expression_in_interval1982 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_ket_in_interval1987 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_TStart_in_interval1997 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_float_expression_in_interval2001 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_TDuration_in_interval2013 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_float_expression_in_interval2017 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_TEnd_in_interval2031 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_float_expression_in_interval2035 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_ket_in_interval2040 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_ket_in_interval2055 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_TEnd_in_interval2077 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_float_expression_in_interval2081 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_ket_in_interval2086 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_DefinitePoint_in_interval2113 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_TStart_in_interval2116 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_float_expression_in_interval2120 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_IndefiniteInterval_in_interval2135 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_bra_in_interval2139 = new BitSet(new long[]{0x000001E000000000L});
    public static final BitSet FOLLOW_TDuration_in_interval2147 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_float_expression_in_interval2151 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_ket_in_interval2156 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_TEnd_in_interval2165 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_float_expression_in_interval2169 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_ket_in_interval2174 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_TStart_in_interval2183 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_float_expression_in_interval2187 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_ket_in_interval2192 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_ket_in_interval2202 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_IndefinitePoint_in_interval2218 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_TBra_in_bra2236 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_At_in_bra2243 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_After_in_bra2252 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Before_in_bra2261 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_expression_in_bra2269 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_TKet_in_ket2295 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_At_in_ket2302 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Before_in_ket2311 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_After_in_ket2320 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_expression_in_ket2328 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_expression_in_timed_expression2366 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_Label_in_expression2388 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_id_in_expression2390 = new BitSet(new long[]{0x0104C8018403C000L,0xFFBFFE3FE04F010CL,0x0000000000000207L});
    public static final BitSet FOLLOW_expression_in_expression2394 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_set_in_expression2403 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_expression2411 = new BitSet(new long[]{0x0104C8018403C000L,0xFFBFFE3FE04F010CL,0x0000000000000207L});
    public static final BitSet FOLLOW_expression_in_expression2415 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_NotEqual_in_expression2424 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_expression2428 = new BitSet(new long[]{0x0104C8018403C000L,0xFFBFFE3FE04F010CL,0x0000000000000207L});
    public static final BitSet FOLLOW_expression_in_expression2432 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_LessThan_in_expression2441 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_expression2445 = new BitSet(new long[]{0x0104C8018403C000L,0xFFBFFE3FE04F010CL,0x0000000000000207L});
    public static final BitSet FOLLOW_expression_in_expression2449 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_GreaterThan_in_expression2458 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_expression2462 = new BitSet(new long[]{0x0104C8018403C000L,0xFFBFFE3FE04F010CL,0x0000000000000207L});
    public static final BitSet FOLLOW_expression_in_expression2466 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_LessThanE_in_expression2475 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_expression2479 = new BitSet(new long[]{0x0104C8018403C000L,0xFFBFFE3FE04F010CL,0x0000000000000207L});
    public static final BitSet FOLLOW_expression_in_expression2483 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_GreaterThanE_in_expression2492 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_expression2496 = new BitSet(new long[]{0x0104C8018403C000L,0xFFBFFE3FE04F010CL,0x0000000000000207L});
    public static final BitSet FOLLOW_expression_in_expression2500 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Assign_in_expression2509 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_expression2513 = new BitSet(new long[]{0x0104C8018403C000L,0xFFBFFE3FE04F010CL,0x0000000000000207L});
    public static final BitSet FOLLOW_expression_in_expression2517 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Undefine_in_expression2526 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_expression2530 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Skip_in_expression2538 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_Change_in_expression2546 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_expression2550 = new BitSet(new long[]{0x0104C8018403C000L,0xFFBFFE3FE04F010CL,0x0000000000000207L});
    public static final BitSet FOLLOW_expression_in_expression2554 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Lend_in_expression2563 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_expression2567 = new BitSet(new long[]{0x0104C8018403C000L,0xFFBFFE3FE04F010CL,0x0000000000000207L});
    public static final BitSet FOLLOW_expression_in_expression2571 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Use_in_expression2580 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_expression2584 = new BitSet(new long[]{0x0104C8018403C000L,0xFFBFFE3FE04F010CL,0x0000000000000207L});
    public static final BitSet FOLLOW_expression_in_expression2588 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Produce_in_expression2597 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_expression2601 = new BitSet(new long[]{0x0104C8018403C000L,0xFFBFFE3FE04F010CL,0x0000000000000207L});
    public static final BitSet FOLLOW_expression_in_expression2605 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Consume_in_expression2614 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_expression2618 = new BitSet(new long[]{0x0104C8018403C000L,0xFFBFFE3FE04F010CL,0x0000000000000207L});
    public static final BitSet FOLLOW_expression_in_expression2622 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Within_in_expression2631 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_expression2633 = new BitSet(new long[]{0x00C0000000000000L});
    public static final BitSet FOLLOW_set_in_expression2635 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_SetAssign_in_expression2644 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_expression2646 = new BitSet(new long[]{0x00C0000000000000L});
    public static final BitSet FOLLOW_set_in_expression2648 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Implies_in_expression2657 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_expression2661 = new BitSet(new long[]{0x0104C8018403C000L,0xFFBFFE3FE04F010CL,0x0000000000000207L});
    public static final BitSet FOLLOW_expression_in_expression2665 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_set_in_expression2674 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_expression2682 = new BitSet(new long[]{0x0104C8018403C000L,0xFFBFFE3FE04F010CL,0x0000000000000207L});
    public static final BitSet FOLLOW_expression_in_expression2686 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_set_in_expression2695 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_expression2703 = new BitSet(new long[]{0x0104C8018403C000L,0xFFBFFE3FE04F010CL,0x0000000000000207L});
    public static final BitSet FOLLOW_expression_in_expression2707 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_set_in_expression2716 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_expression2724 = new BitSet(new long[]{0x0104C8018403C000L,0xFFBFFE3FE04F010CL,0x0000000000000207L});
    public static final BitSet FOLLOW_expression_in_expression2728 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Plus_in_expression2737 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_expression2741 = new BitSet(new long[]{0x0104C8018403C000L,0xFFBFFE3FE04F010CL,0x0000000000000207L});
    public static final BitSet FOLLOW_expression_in_expression2745 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Minus_in_expression2754 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_expression2758 = new BitSet(new long[]{0x0104C8018403C000L,0xFFBFFE3FE04F010CL,0x0000000000000207L});
    public static final BitSet FOLLOW_expression_in_expression2762 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Times_in_expression2771 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_expression2775 = new BitSet(new long[]{0x0104C8018403C000L,0xFFBFFE3FE04F010CL,0x0000000000000207L});
    public static final BitSet FOLLOW_expression_in_expression2779 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Divide_in_expression2788 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_expression2792 = new BitSet(new long[]{0x0104C8018403C000L,0xFFBFFE3FE04F010CL,0x0000000000000207L});
    public static final BitSet FOLLOW_expression_in_expression2796 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_ForallExpr_in_expression2805 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_Parameters_in_expression2814 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_scope_arg_decl_list_in_expression2816 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_expression_in_expression2822 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_ExistsExpr_in_expression2831 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_Parameters_in_expression2839 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_scope_arg_decl_list_in_expression2841 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_expression_in_expression2847 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_ContainsSomeExpr_in_expression2856 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_interval_in_expression2862 = new BitSet(new long[]{0x0104C8018403C000L,0xFFBFFE3FE04F010CL,0x0000000000000207L});
    public static final BitSet FOLLOW_timed_expression_in_expression2867 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_ContainsAllExpr_in_expression2881 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_boolean_expression_in_expression2885 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_TimedExpr_in_expression2898 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_interval_in_expression2902 = new BitSet(new long[]{0x0104C8018403C000L,0xFFBFFE3FE04F010CL,0x0000000000000207L});
    public static final BitSet FOLLOW_timed_expression_in_expression2907 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Unordered_in_expression2917 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_boolean_expression_in_expression2924 = new BitSet(new long[]{0x0104C8018403C008L,0xFFBFFE3FE04F010CL,0x0000000000000207L});
    public static final BitSet FOLLOW_Ordered_in_expression2935 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_boolean_expression_in_expression2942 = new BitSet(new long[]{0x0104C8018403C008L,0xFFBFFE3FE04F010CL,0x0000000000000207L});
    public static final BitSet FOLLOW_set_in_expression2953 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_ref_in_expression2969 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_expression_in_expression2979 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_ref_in_expression2995 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_Delta_in_expression3003 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_ref_in_expression3005 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_literal_in_expression3011 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_time_primitive_in_expression3018 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_identifier_ref_in_ref3041 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_field_ref_in_ref3048 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_term_ref_in_ref3055 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_Ref_in_identifier_ref3073 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_id_in_identifier_ref3075 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Access_in_field_ref3094 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_ref_in_field_ref3096 = new BitSet(new long[]{0x0000000000008000L});
    public static final BitSet FOLLOW_identifier_ref_in_field_ref3098 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Bind_in_term_ref3124 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_identifier_ref_in_term_ref3128 = new BitSet(new long[]{0x0000000000000200L});
    public static final BitSet FOLLOW_bind_arg_list_in_term_ref3135 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Arguments_in_bind_arg_list3154 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_bind_arg_list3157 = new BitSet(new long[]{0x0104C8018403C008L,0xFFBFFE3FE04F010CL,0x0000000000000207L});
    public static final BitSet FOLLOW_Arguments_in_bind_arg_list3168 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_LabelRef_in_time_primitive3184 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_id_in_time_primitive3186 = new BitSet(new long[]{0x0000000180000000L,0x0180000000400000L});
    public static final BitSet FOLLOW_Start_in_time_primitive3194 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_End_in_time_primitive3203 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Duration_in_time_primitive3212 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Bra_in_time_primitive3221 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Ket_in_time_primitive3230 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_Start_in_time_primitive3246 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_End_in_time_primitive3253 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_Duration_in_time_primitive3261 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_Bra_in_time_primitive3268 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_Ket_in_time_primitive3275 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_enumeration_in_set3295 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_range_in_set3302 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_Enum_in_enumeration3325 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_enumeration3329 = new BitSet(new long[]{0x0104C8018403C008L,0xFFBFFE3FE04F010CL,0x0000000000000207L});
    public static final BitSet FOLLOW_expression_in_enumeration3339 = new BitSet(new long[]{0x0104C8018403C008L,0xFFBFFE3FE04F010CL,0x0000000000000207L});
    public static final BitSet FOLLOW_Range_in_range3365 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_range3369 = new BitSet(new long[]{0x0104C8018403C000L,0xFFBFFE3FE04F010CL,0x0000000000000207L});
    public static final BitSet FOLLOW_expression_in_range3373 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_INT_in_literal3395 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_FLOAT_in_literal3404 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_STRING_in_literal3413 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_True_in_literal3423 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_False_in_literal3432 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_Infinity_in_literal3441 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_ID_in_literal3451 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_ref_in_synpred1_ANMLTree2965 = new BitSet(new long[]{0x0000000000000002L});

}